Bug 3693

Summary: libpthreads on SMP: condvar queueing broken
Product: [Retired] Red Hat Linux Reporter: robey
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0CC: shaver
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.lag.net/~robey/pthreads/
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-07-09 21:55:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description robey 1999-06-24 03:09:24 UTC
The pthreads library in glibc 2.1 uses only one "next"
pointer in the thread descriptor -- with the assumption
that a thread will only be queued for one thing at a time.
The CV (condition variable) code, however, uses a queue for
threads waiting on a CV, and uses a lock for synchronizing
this queue.  The lock uses a queue when there is
contention, so a thread can end up sitting on a CV queue,
and attempting to get a lock (to remove itself from the CV
queue), but queueing on the lock.

The URL points to a program (swarm.c) that will duplicate
the bug on 2-CPU machines (tweak the #define's for a 4-way)
by creating 20 threads that keep waiting 1 second on a
single CV.  Every second, all 20 threads dequeue from the
CV and then requeue.

The URL also points to a patch (patch.glibc) for the
linuxthreads library to fix this bug.  It adds a second
"next" pointer to the thread descriptor so that a thread
can be queued for some event (like a CV) and also queue on
a lock for internal synchronization.

I have also emailed this patch to Ulrich Drepper
<drepper> of the glibc team.

Comment 1 robey 1999-07-07 23:25:59 UTC
since you can't see the url in the normal bug printout (why?), i'll
echo it here:
    http://www.lag.net/~robey/pthreads/

Comment 2 Cristian Gafton 1999-07-09 21:55:59 UTC
Fixed in glibc-2.1.2-1, available from rawhide shortly