[Bug libc/5240] New: Pthread hang where there are still waiters when mutex is in "unlocked" state.
rsa at us dot ibm dot com
sourceware-bugzilla@sourceware.org
Thu Nov 1 17:03:00 GMT 2007
A customer identified a potential race condition in
nptl/sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait) which causes
waiting threads not to be woken up under certain circumstances.
Reproduced on:
SMP PowerPC 970
SMP POWER6 (with SMT)
SMP POWER5 (with SMT)
Uni PowerPC 440
Not reproduced on:
Uni Intel Pentium M.
SMP Intel Core 2 Duo.
Consider three threads, "A" holding a lock, "B" blocked in a timed
wait on the same lock, and "C" also blocked on that lock. The value of
the futex is 2. Then:
- "A" releases the lock, setting the futex value to 0 and waking up
"B".
- Before "B" performs any further action, "A" continues to execute and
acquires the lock again, setting the futex value to 1.
- "B" checks the while condition in __lll_timedlock_wait:
while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
The condition is true, so "B" iterates the do-while loop.
- "B" hits the timeout and returns ETIMEDOUT.
- "A" releases the lock, setting the futex value from 1 to 0 (without
wakeup).
At the end, "C" is left waiting, and the futex value is 0.
Testcase forthcoming...
--
Summary: Pthread hang where there are still waiters when mutex is
in "unlocked" state.
Product: glibc
Version: unspecified
Status: NEW
Severity: critical
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: rsa at us dot ibm dot com
CC: glibc-bugs at sources dot redhat dot com,rsa at us dot
ibm dot com
GCC build triplet: powerpc-linux
GCC host triplet: powerpc-linux
GCC target triplet: powerpc-linux
http://sourceware.org/bugzilla/show_bug.cgi?id=5240
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the Glibc-bugs
mailing list