Red Hat Bugzilla – Bug 61353
Sharing pthread mutexes between threads, that are created recursively by the new threads, cause segmentation faults.
Last modified: 2016-11-24 09:54:55 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686)
Description of problem:
The linux threads library seems to segfault when sharing mutexes between threads
that are created recursively. The routine that I used to display this bug goes
1) Create a thread that has atomic variable protected by a mutex
2) use the parent thread for atomically changing a variable and condvar for
signalling the change
3) on receival of the signal the child thread will create a new child that will
act in a similar manner.
Loop that rapidly for a while and linux threads will do a segmentation fault.
See the attached code that runs smoothly on solaris.
I managed to reproduce the problem on atleast:
2.4.2-2 kernel, 2.2.4-13 glibc
2.4.9-31 kernel, 2.2.4-19.3 glibc
2.4.17 kernel, 2.2.4-19.3 glibc
2.4.9-21smp kernel, 2.2.4-19.3 glibc
On SMP machine segmentation faults were not as common, but pthread_mutex calls
failed with EINVAL although everything should've been in order.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. compile the accompanied example
2. execute the compiled binary at CLI in while loop
3. see the segmentation faults happend.
Created attachment 48845 [details]
cpp-source file and Makefile for building it
There is a bug in the tester itself. In main() the parent_thread thr_handle is within the stack. Once the main exits the handle is freed although threads that are still running use the handle. This obiviously causes the segmentation faults.
I will look in more depth in order to figure out, wether the bug is valid or not...
Works for in 3.2