diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-09-24 18:20:01 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-09-24 18:20:01 +0000 |
commit | ebfa58bb230933c35798a83f99a7a0c95c9d2217 (patch) | |
tree | d6954eb8d9e49c86b1336cc585f3cd31fd8412cd /nptl | |
parent | 24f076f84e25e5938d6d6e17d94ed3b7bbb4cc24 (diff) | |
download | glibc-ebfa58bb230933c35798a83f99a7a0c95c9d2217.tar.gz glibc-ebfa58bb230933c35798a83f99a7a0c95c9d2217.tar.xz glibc-ebfa58bb230933c35798a83f99a7a0c95c9d2217.zip |
(__pthread_create_2_1): Remember whether thread is created detached and if yes, do not try to free the stack in case the thread creation failed.
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/pthread_create.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 14306867c9..34cc37d527 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -447,13 +447,19 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg) /* Pass the descriptor to the caller. */ *newthread = (pthread_t) pd; + /* Remember whether the thread is detached or not. In case of an + error we have to free the stacks of non-detached stillborn + threads. */ + bool is_detached = IS_DETACHED (pd); + /* Start the thread. */ err = create_thread (pd, iattr, STACK_VARIABLES_ARGS); if (err != 0) { errout: /* Something went wrong. Free the resources. */ - __deallocate_stack (pd); + if (!is_detached) + __deallocate_stack (pd); return err; } |