Red Hat Bugzilla – Bug 122979
PTHREAD_PROCESS_SHARED condition variable does not work if addresses different in different processes
Last modified: 2007-11-30 17:07:01 EST
Description of problem:
When using an inter-process pthread_cond_t (i.e. initialised with
PTHREAD_PROCESS_SHARED attribute set), waiters are only reliably
woken if the address of the condition variable and associated mutex
is the same in both the waiter and the broadcaster. It should be
possible to map the condition variable and associated mutex at any
Version-Release number of selected component (if applicable):
My glibc has NPTL 0.60.
Every time, using the attached source.
Steps to Reproduce:
1. Compile and run the "server" program with the command line g++ -
pthread -o server server.cc
2. Compile and run the "client" program with the command line g++ -
pthread -o client client.cc
The client hangs, waiting on the condition variable, and is never
The client should be woken.
Commenting out the two lines at the top of the client - which open
and map the first page of the client binary - are there to ensure
that the address of the condvar mapping is different in the two
processes. If commented out, the mapping addresses are the same in
client and server and running the test gives the expected result.
Created attachment 100143 [details]
Header file defining shared structures used by both test programs.
Created attachment 100144 [details]
Server test program - initialises it and broadcasts on the CV
Created attachment 100145 [details]
Client program - maps the CV then waits on it.
Comment out the first open and mmap for the test case to work.
What exact glibc you're using?
Works just fine for me with glibc-2.3.2-95.20 (RHEL3 U2 glibc).
I think this is fixed by glibc-nptl-pshared-condvar.patch.
You should be able to fetch -95.20 from RHN or it is ATM available
Many thanks for your speedy response, Jakub. I'm using glibc-2.3.2-
95.3 - the glibc which shipped with the initial release of RHEL3. I
haven't updated my machine since then, but I will do so and try again.
I've installed the updated packages, and both the test case and my
application work fine.
Many thanks again for the help, Jakub.