[LLVMbugs] [Bug 19041] New: condition_variable tests delete condition_variable while it is being waited upon

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 4 08:05:33 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=19041

            Bug ID: 19041
           Summary: condition_variable tests delete condition_variable
                    while it is being waited upon
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: russell_gallop at sn.scee.net
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

Created attachment 12183
  --> http://llvm.org/bugs/attachment.cgi?id=12183&action=edit
Patch for tests

The tests:
thread/thread.condition/thread.condition.condvar/destructor.pass.cpp and
thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp

 delete their condition variables while they are being waited on.

clang version 3.4
libcxx revision 202832
Ubuntu 12.10

This can be seen with the valgrind DRD tool (see below). It is fixed with the
attached patch (for both tests) which moves the delete to main(). It would also
be possible to rewrite the test so cv is not a pointer at all.

$ valgrind --tool=drd condvar
==14176== drd, a thread error detector
==14176== Copyright (C) 2006-2013, and GNU GPL'd, by Bart Van Assche.
==14176== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==14176== Command: condvar
==14176==
==14176== Thread 3:
==14176== destruction of condition variable being waited upon: cond 0x60e4030
==14176==    at 0x4C332F2: pthread_cond_destroy@*
(drd_pthread_intercepts.c:719)
==14176==    by 0x400FA8: f() (destructor.pass.cpp:33)
==14176==    by 0x40189D: _ZNSt3__114__thread_proxyINS_5tupleIJPFvvEEEEEEPvS5_
(__functional_base:413)
==14176==    by 0x4C2EDA4: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355)
==14176==    by 0x59C3E99: start_thread (pthread_create.c:308)
==14176==    by 0x56F03FC: clone (clone.S:112)
==14176== cond 0x60e4030 was first observed at:
==14176==    at 0x4C34042: pthread_cond_signal@* (drd_pthread_intercepts.c:778)
==14176==    by 0x401027: g() (destructor.pass.cpp:40)
==14176==    by 0x40189D: _ZNSt3__114__thread_proxyINS_5tupleIJPFvvEEEEEEPvS5_
(__functional_base:413)
==14176==    by 0x4C2EDA4: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355)
==14176==    by 0x59C3E99: start_thread (pthread_create.c:308)
==14176==    by 0x56F03FC: clone (clone.S:112)
==14176==
==14176== Destroying condition variable that is being waited upon: cond
0x60e4030, mutex 0x6030f0 locked by thread 3
==14176==    at 0x4C332F2: pthread_cond_destroy@*
(drd_pthread_intercepts.c:719)
==14176==    by 0x400FA8: f() (destructor.pass.cpp:33)
==14176==    by 0x40189D: _ZNSt3__114__thread_proxyINS_5tupleIJPFvvEEEEEEPvS5_
(__functional_base:413)
==14176==    by 0x4C2EDA4: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355)
==14176==    by 0x59C3E99: start_thread (pthread_create.c:308)
==14176==    by 0x56F03FC: clone (clone.S:112)
==14176== mutex 0x6030f0 was first observed at:
==14176==    at 0x4C3194E: pthread_mutex_lock (drd_pthread_intercepts.c:627)
==14176==    by 0x4EB4927: std::__1::mutex::lock() (mutex.cpp:30)
==14176==    by 0x401012: g() (__mutex_base:108)
==14176==    by 0x40189D: _ZNSt3__114__thread_proxyINS_5tupleIJPFvvEEEEEEPvS5_
(__functional_base:413)
==14176==    by 0x4C2EDA4: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355)
==14176==    by 0x59C3E99: start_thread (pthread_create.c:308)
==14176==    by 0x56F03FC: clone (clone.S:112)
==14176==
==14176== Thread 2:
==14176== condition variable has been destroyed while being waited upon: cond
0x60e4030, mutex 0x0 locked by thread 0
==14176==    at 0x4C33793: pthread_cond_wait@* (drd_pthread_intercepts.c:736)
==14176==    by 0x4E82C79:
std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&)
(condition_variable.cpp:40)
==14176==    by 0x40104D: g() (destructor.pass.cpp:42)
==14176==    by 0x40189D: _ZNSt3__114__thread_proxyINS_5tupleIJPFvvEEEEEEPvS5_
(__functional_base:413)
==14176==    by 0x4C2EDA4: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355)
==14176==    by 0x59C3E99: start_thread (pthread_create.c:308)
==14176==    by 0x56F03FC: clone (clone.S:112)
==14176==
==14176==
==14176== For counts of detected and suppressed errors, rerun with: -v
==14176== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 54 from 48)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140304/a6337575/attachment.html>


More information about the llvm-bugs mailing list