Group binding needs to be cleared before sched_releasetcb(), as otherwise group_leave() will be called and group->tg_nmembers decremented or group being released. group_leave() should be called only after group_join() is called, not after group_bind(). From Jussi Kivilinna.
This commit is contained in:
parent
464390193e
commit
13d9383679
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* sched/pthread/pthread_create.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -241,6 +241,9 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
||||
int errcode;
|
||||
pid_t pid;
|
||||
int ret;
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
bool group_joined = false;
|
||||
#endif
|
||||
|
||||
/* If attributes were not supplied, use the default attributes */
|
||||
|
||||
@ -368,6 +371,8 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
||||
errcode = ENOMEM;
|
||||
goto errout_with_join;
|
||||
}
|
||||
|
||||
group_joined = true;
|
||||
#endif
|
||||
|
||||
/* Attach the join info to the TCB. */
|
||||
@ -451,6 +456,15 @@ errout_with_join:
|
||||
ptcb->joininfo = NULL;
|
||||
|
||||
errout_with_tcb:
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
/* Clear group binding */
|
||||
|
||||
if (ptcb && !group_joined)
|
||||
{
|
||||
ptcb->cmn.group = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
sched_releasetcb((FAR struct tcb_s *)ptcb, TCB_FLAG_TTYPE_PTHREAD);
|
||||
return errcode;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user