summaryrefslogtreecommitdiff
path: root/pthread/pt-create.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2013-06-29 10:48:21 +0200
committerRichard Braun <rbraun@sceen.net>2013-06-29 10:48:21 +0200
commitb9eb71a78f15f5f889114fb1f5393be74789039d (patch)
treeb6454eb71d35fde549112121687232d05f4a44d7 /pthread/pt-create.c
parentff1ae3d79b2d103f211ad4c600e144ad448a98e6 (diff)
Fix a subtle thread creation bug
* pthread/pt-create.c (__pthread_create_internal): Store pthread ID in caller-provided memory before starting the new thread.
Diffstat (limited to 'pthread/pt-create.c')
-rw-r--r--pthread/pt-create.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index 9ce0be8..a88c498 100644
--- a/pthread/pt-create.c
+++ b/pthread/pt-create.c
@@ -195,16 +195,16 @@ __pthread_create_internal (struct __pthread **thread,
/* At this point it is possible to guess our pthread ID. We have to
make sure that all functions taking a pthread_t argument can
- handle the fact that this thread isn't really running yet. */
+ handle the fact that this thread isn't really running yet. Since
+ the new thread might be passed its ID through pthread_create (to
+ avoid calling pthread_self), read it before starting the thread. */
+ *thread = pthread;
/* Schedule the new thread. */
err = __pthread_thread_start (pthread);
if (err)
goto failed_starting;
- /* At this point the new thread is up and running. */
-
- *thread = pthread;
return 0;