From bd7c3bed543d02fb01f69b29ea1a736e7a0f618d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 25 Sep 2004 07:55:46 +0000 Subject: Updated to fedora-glibc-20040925T0738 --- nptl/sysdeps/pthread/createthread.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'nptl/sysdeps/pthread/createthread.c') diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c index 49383cf769..8620519887 100644 --- a/nptl/sysdeps/pthread/createthread.c +++ b/nptl/sysdeps/pthread/createthread.c @@ -66,8 +66,16 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, if (ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags, pd, &pd->tid, TLS_VALUE, &pd->tid) == -1) - /* Failed. */ - return errno; + { + /* Failed. If the thread is detached, remove the TCB here since + the caller cannot do this. The caller remembered the thread + as detached and cannot reverify that it is not since it must + not access the thread descriptor again. */ + if (IS_DETACHED (pd)) + __deallocate_stack (pd); + + return errno; + } /* Now we have the possibility to set scheduling parameters etc. */ if (__builtin_expect (stopped != 0, 0)) @@ -95,7 +103,9 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, (void) INTERNAL_SYSCALL (tkill, err2, 2, pd->tid, SIGCANCEL); #endif - return INTERNAL_SYSCALL_ERRNO (res, err); + return (INTERNAL_SYSCALL_ERROR_P (res, err) + ? INTERNAL_SYSCALL_ERRNO (res, err) + : 0); } } @@ -176,6 +186,9 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, if ((_mask & (__nptl_threads_events.event_bits[_idx] | pd->eventbuf.eventmask.event_bits[_idx])) != 0) { + /* We always must have the thread start stopped. */ + pd->stopped_start = true; + /* Create the thread. We always create the thread stopped so that it does not get far before we tell the debugger. */ int res = do_clone (pd, attr, clone_flags, start_thread, @@ -214,10 +227,11 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, /* Determine whether the newly created threads has to be started stopped since we have to set the scheduling parameters or set the affinity. */ - int stopped = 0; + bool stopped = false; if (attr != NULL && (attr->cpuset != NULL || (attr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0)) - stopped = 1; + stopped = true; + pd->stopped_start = stopped; /* Actually create the thread. */ int res = do_clone (pd, attr, clone_flags, start_thread, -- cgit 1.4.1