sched: group: Fix dataabort when exiting task or pthread if ARCH_ADDRENV=y

Summary:
- I noticed that exiting task or pthread causes dataabort if ARCH_ADDRENV=y
- This commit fixes this issue by switching the addrenv correctly

Impact:
- CONFIG_ARCH_ADDRENV=y only

Testing:
- Tested with sabre-6quad:netknsh (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2022-02-27 21:39:43 +09:00 committed by Xiang Xiao
parent 56e0e6a5ec
commit dcafd95971
2 changed files with 32 additions and 5 deletions

View File

@ -244,13 +244,39 @@ void group_deallocate(FAR struct task_group_s *group)
{
if (group)
{
#ifdef CONFIG_ARCH_ADDRENV
save_addrenv_t oldenv;
/* NOTE: switch the addrenv before accessing group->tg_info
* located in the userland, also save the current addrenv
*/
up_addrenv_select(&group->tg_addrenv, &oldenv);
#endif
if (group->tg_info)
{
nxsem_destroy(&group->tg_info->ta_sem);
group_free(group, group->tg_info);
}
#ifdef CONFIG_ARCH_ADDRENV
/* Destroy the group address environment */
up_addrenv_destroy(&group->tg_addrenv);
/* Mark no address environment */
g_pid_current = INVALID_PROCESS_ID;
#endif
kmm_free(group);
#ifdef CONFIG_ARCH_ADDRENV
/* Restore the previous addrenv */
up_addrenv_restore(&oldenv);
#endif
}
}

View File

@ -175,11 +175,12 @@ static inline void group_release(FAR struct task_group_s *group)
#endif
#ifdef CONFIG_ARCH_ADDRENV
/* Destroy the group address environment */
up_addrenv_destroy(&group->tg_addrenv);
/* Mark no address environment */
/* NOTE:
* We do not destroy the group address environment here.
* It will be done in the group_deallocate().
* However, we mark no address environment here,
* so that group_addrenv() can work correctly
*/
g_pid_current = INVALID_PROCESS_ID;
#endif