You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lib/pthread: Fix create/join race in thread lifecycle
The pthread_join() implementation was done using a condition variable
and not k_thread_join(), and that's actually fatal. It's not possible
in Zephyr to guarantee a thread has exited in a race-free way without
calling either k_thread_abort() or k_thread_join().
This opened a hole where an app could call pthread_join(), which would
go to sleep waiting on the condition variable, which would be signaled
from the exit path of the thread, and then return to call
pthread_create() (and thus k_thread_create()) on the same pthread_t
object (and thus the same struct k_thread) BEFORE THE EARLIER THREAD
HAD ACTUALLY EXITED.
This makes the scheduler blow up, at least on SMP (I wasn't personally
able to make it happen on uniprocessor configs, though the race is
present always).
Rework to call k_thread_join(). There's no other correct way to do
this.
Fixeszephyrproject-rtos#56163
Signed-off-by: Andy Ross <[email protected]>
0 commit comments