Bug 122979

Summary: PTHREAD_PROCESS_SHARED condition variable does not work if addresses different in different processes
Product: Red Hat Enterprise Linux 3 Reporter: Philip Beevers <philip.beevers>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-05-11 16:59:39 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
Header file defining shared structures used by both test programs.
none
Server test program - initialises it and broadcasts on the CV
none
Client program - maps the CV then waits on it. none

Description Philip Beevers 2004-05-10 18:02:45 EDT
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 
address.


Version-Release number of selected component (if applicable):

My glibc has NPTL 0.60.


How reproducible:

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
  
Actual results:

The client hangs, waiting on the condition variable, and is never 
woken.


Expected results:

The client should be woken.


Additional info:

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.
Comment 1 Philip Beevers 2004-05-10 18:04:55 EDT
Created attachment 100143 [details]
Header file defining shared structures used by both test programs.
Comment 2 Philip Beevers 2004-05-10 18:05:24 EDT
Created attachment 100144 [details]
Server test program - initialises it and broadcasts on the CV
Comment 3 Philip Beevers 2004-05-10 18:06:48 EDT
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.
Comment 4 Jakub Jelinek 2004-05-10 18:27:16 EDT
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
from
ftp://people.redhat.com/jakub/glibc/errata/2.3.2-95.20/
Comment 5 Philip Beevers 2004-05-11 02:02:49 EDT
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.
Comment 6 Philip Beevers 2004-05-11 16:59:39 EDT
I've installed the updated packages, and both the test case and my 
application work fine.

Many thanks again for the help, Jakub.