<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - condition_variable tests delete condition_variable while it is being waited upon"
   href="http://llvm.org/bugs/show_bug.cgi?id=19041">19041</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>condition_variable tests delete condition_variable while it is being waited upon
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>russell_gallop@sn.scee.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12183" name="attach_12183" title="Patch for tests">attachment 12183</a> <a href="attachment.cgi?id=12183&action=edit" title="Patch for tests">[details]</a></span>
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)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>