sched: fix pthread_exit crash

A normal user task calls pthread_exit(), will crash at DEBUGASSERT.
Cause pthread_exit limit in user pthread task.

test case:
int main(int argc, FAR char *argv[])
{
  pthread_exit(NULL);
  return 0;
}
>> test
>> echo $?
>> 0

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
fangxinyong 2023-06-23 22:19:56 +08:00 committed by Xiang Xiao
parent 1d6e51220d
commit d08b81db9d
2 changed files with 4 additions and 2 deletions

View File

@ -203,7 +203,10 @@ int pthread_completejoin(pid_t pid, FAR void *exit_value)
if (ret != OK)
{
nxmutex_unlock(&group->tg_joinlock);
return tcb->flags & TCB_FLAG_DETACHED ? OK : ERROR;
return ((tcb->flags & TCB_FLAG_DETACHED) ||
(tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_PTHREAD) ?
OK : ERROR;
}
else
{

View File

@ -69,7 +69,6 @@ void nx_pthread_exit(FAR void *exit_value)
sinfo("exit_value=%p\n", exit_value);
DEBUGASSERT(tcb != NULL);
DEBUGASSERT((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD);
/* Block any signal actions that would awaken us while were
* are performing the JOIN handshake.