public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/9691] New: pthread race condition causes tst-mutex8 to fail
@ 2008-12-29 12:26 billmason_sp2 at yahoo dot com
  2009-01-25 17:53 ` [Bug nptl/9691] " drepper at redhat dot com
  0 siblings, 1 reply; 3+ messages in thread
From: billmason_sp2 at yahoo dot com @ 2008-12-29 12:26 UTC (permalink / raw)
  To: glibc-bugs

tst-mutex8 usually runs fine but occasionally (~10% of the time) fails with this
error:
cl: mutex_unlocked failed

So I tried adding print statements to tst-mutex8.c, pthread_mutex_lock.c, and
pthread_mutex_unlock.c to trace them, and I'm pretty sure there is a race
condition.  It only happens for recursive locks.

check_type creates the thread and calls pthread_barrier_wait.  tf (the thread)
locks the mutex, and calls pthread_barrier_wait.  create_type then does an extra
lock and unlock, then cancels the thread.  Meanwhile, tf has added cl to its
cleanup, and is in pthread_cond_wait, which unlocks the mutex at the beginning
and locks it at the end.  But before the lock happens, the thread has been
canceled, and cl is called, which calls unlock again, after nusers is already 0.
 It returns EPERM and tst-mutex8 fails.

The way to replicate the problem is to run tst-mutex8, but I presume plenty of
developers have done this already.  It's a race condition, which makes it very
difficult to replicate.  Hopefully it can be replicated by running it a few
hundred times in a loop.  Otherwise, I hope you can check the code to see if I'm
correct that there is a race condition.  I might be missing something, as I'm
not familiar with this code, but it looks like a race condition from the few
hours of debugging I did.

Here are the details of the system that has produced this problem:
glibc-2.8-20081222
i686-pc-linux-gnu
Options to configure: --prefix=/usr --disable-profile --enable-add-ons    
--enable-kernel=2.6.0 --libexecdir=/usr/lib/glibc
configparms: CFLAGS += -march=i486 -mtune=native
I'm experiencing this while trying to build Linux From Scratch 6.4:
http://www.linuxfromscratch.org/lfs/view/stable/chapter06/glibc.html
Host system: Debian etch
Kernel: 2.6.18-6-686 #1 SMP Fri Dec 12 16:48:28 UTC 2008 i686 GNU/Linux
GCC version: 4.3.2
GNU ld version: 2.18

-- 
           Summary: pthread race condition causes tst-mutex8 to fail
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: billmason_sp2 at yahoo dot com
                CC: billmason_sp2 at yahoo dot com,glibc-bugs at sources dot
                    redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=9691

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <bug-9691-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2014-07-02  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-29 12:26 [Bug nptl/9691] New: pthread race condition causes tst-mutex8 to fail billmason_sp2 at yahoo dot com
2009-01-25 17:53 ` [Bug nptl/9691] " drepper at redhat dot com
     [not found] <bug-9691-131@http.sourceware.org/bugzilla/>
2014-07-02  7:35 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).