Bug 7008 - pthread_condattr_setclock will modify the attribute of condition to PTHREAD_PROCESS_PRIVATE
Summary: pthread_condattr_setclock will modify the attribute of condition to PTHREAD_P...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-06 02:06 UTC by chuli
Modified: 2014-07-01 21:19 UTC (History)
1 user (show)

See Also:
Host: x86
Target: x86
Build: x86
Last reconfirmed:
fweimer: security-


Attachments
This is the patch for pthread_condattr_setclock not to modify the condition attribute (233 bytes, patch)
2008-11-06 02:14 UTC, chuli
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chuli 2008-11-06 02:06:18 UTC
When I make some tests for nptl, I found pthread_condattr_setclock will always 
modify the attribute of condition to PTHREAD_PROCESS_PRIVATE, even if the 
condition is set as PTHREAD_PROCESS_SHARED at first. So the program will be 
hung if condition is used for LWP.

The following line is wrong in nptl/pthread_condattr_setclock.c:

*valuep = ((*valuep & ~(1 << (COND_NWAITERS_SHIFT + 1)) & ~1)
	     | (clock_id << 1));

I think it should be correct as follows:

*valuep = ((*valuep & ~(1 << (COND_NWAITERS_SHIFT + 1)) & ~0)
	     | (clock_id << 1));
Comment 1 chuli 2008-11-06 02:14:42 UTC
Created attachment 3044 [details]
This is the patch for pthread_condattr_setclock not to modify the condition attribute
Comment 2 Seiichi Ikarashi 2008-11-12 02:55:28 UTC
I think it should be

    *valuep = ((*valuep & ~(((1 << COND_NWAITERS_SHIFT + 1) - 1) & ~1)) 
               | (clock_id << 1));

in order to correspond to pthread_condattr_getclock().
Comment 3 Ulrich Drepper 2008-11-12 13:39:59 UTC
Fix checked into cvs.