pthread detach problem with glibc 2.2 on SMP

Ulrich Drepper drepper@redhat.com
Wed Dec 6 00:24:00 GMT 2000


Andreas Jaeger <aj@suse.de> writes:

> The following program compiled with:
> gcc -o pthread-test -g -O2 pthread-test.c -lpthread -Wall
> 
> gives sometimes (try it at least 20 times) on an SMP system as result:
> abc: Interrupted system call
> def: Invalid argument

The behavior is correct.  pthread_detach() returns ESRCH if the thread
ID is not valid.  This can happen if the newly created thread gets
scheduled before the creating thread.  It's a simple race condition.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------


More information about the Libc-alpha mailing list