<div dir="ltr">Strange, I'll take a look tomorrow.  Thanks for catching this</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 17, 2015 at 5:28 PM Chaoren Lin via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chaoren<br>
Date: Mon Aug 17 19:27:08 2015<br>
New Revision: 245262<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=245262&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=245262&view=rev</a><br>
Log:<br>
Revert part of "Convert all use of pthreads in tests to c++11 threads."<br>
<br>
TestExprDoesntBlock started failing because deadlocks behave differently with<br>
pthread_mutex and std::mutex.<br>
<br>
This reverts part of commit r245234.<br>
<br>
Added:<br>
    lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c<br>
Removed:<br>
    lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp<br>
Modified:<br>
    lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile<br>
    lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py<br>
<br>
Modified: lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile?rev=245262&r1=245261&r2=245262&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile?rev=245262&r1=245261&r2=245262&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile (original)<br>
+++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile Mon Aug 17 19:27:08 2015<br>
@@ -1,6 +1,6 @@<br>
 LEVEL = ../../make<br>
<br>
-CXX_SOURCES := locking.cpp<br>
+C_SOURCES := locking.c<br>
 ENABLE_THREADS := YES<br>
<br>
 include $(LEVEL)/Makefile.rules<br>
<br>
Modified: lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py?rev=245262&r1=245261&r2=245262&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py?rev=245262&r1=245261&r2=245262&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py (original)<br>
+++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Mon Aug 17 19:27:08 2015<br>
@@ -44,7 +44,7 @@ class ExprDoesntDeadlockTestCase(TestBas<br>
<br>
         # Now create a breakpoint at source line before call_me_to_get_lock gets called.<br>
<br>
-        main_file_spec = lldb.SBFileSpec ("locking.cpp")<br>
+        main_file_spec = lldb.SBFileSpec ("locking.c")<br>
         breakpoint = target.BreakpointCreateBySourceRegex('Break here', main_file_spec)<br>
         if self.TraceOn():<br>
             print "breakpoint:", breakpoint<br>
<br>
Added: lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c?rev=245262&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c?rev=245262&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c (added)<br>
+++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c Mon Aug 17 19:27:08 2015<br>
@@ -0,0 +1,80 @@<br>
+#include <pthread.h><br>
+#include <stdlib.h><br>
+#include <unistd.h><br>
+#include <stdio.h><br>
+<br>
+pthread_mutex_t contended_mutex = PTHREAD_MUTEX_INITIALIZER;<br>
+<br>
+pthread_mutex_t control_mutex = PTHREAD_MUTEX_INITIALIZER;<br>
+pthread_cond_t  control_condition;<br>
+<br>
+pthread_mutex_t thread_started_mutex = PTHREAD_MUTEX_INITIALIZER;<br>
+pthread_cond_t  thread_started_condition;<br>
+<br>
+// This function runs in a thread.  The locking dance is to make sure that<br>
+// by the time the main thread reaches the pthread_join below, this thread<br>
+// has for sure acquired the contended_mutex.  So then the call_me_to_get_lock<br>
+// function will block trying to get the mutex, and only succeed once it<br>
+// signals this thread, then lets it run to wake up from the cond_wait and<br>
+// release the mutex.<br>
+<br>
+void *<br>
+lock_acquirer_1 (void *input)<br>
+{<br>
+  pthread_mutex_lock (&contended_mutex);<br>
+<br>
+  // Grab this mutex, that will ensure that the main thread<br>
+  // is in its cond_wait for it (since that's when it drops the mutex.<br>
+<br>
+  pthread_mutex_lock (&thread_started_mutex);<br>
+  pthread_mutex_unlock(&thread_started_mutex);<br>
+<br>
+  // Now signal the main thread that it can continue, we have the contended lock<br>
+  // so the call to call_me_to_get_lock won't make any progress till  this<br>
+  // thread gets a chance to run.<br>
+<br>
+  pthread_mutex_lock (&control_mutex);<br>
+<br>
+  pthread_cond_signal (&thread_started_condition);<br>
+<br>
+  pthread_cond_wait (&control_condition, &control_mutex);<br>
+<br>
+  pthread_mutex_unlock (&contended_mutex);<br>
+  return NULL;<br>
+}<br>
+<br>
+int<br>
+call_me_to_get_lock ()<br>
+{<br>
+  pthread_cond_signal (&control_condition);<br>
+  pthread_mutex_lock (&contended_mutex);<br>
+  return 567;<br>
+}<br>
+<br>
+int main ()<br>
+{<br>
+  pthread_t thread_1;<br>
+<br>
+  pthread_cond_init (&control_condition, NULL);<br>
+  pthread_cond_init (&thread_started_condition, NULL);<br>
+<br>
+  pthread_mutex_lock (&thread_started_mutex);<br>
+<br>
+  pthread_create (&thread_1, NULL, lock_acquirer_1, NULL);<br>
+<br>
+  pthread_cond_wait (&thread_started_condition, &thread_started_mutex);<br>
+<br>
+  pthread_mutex_lock (&control_mutex);<br>
+  pthread_mutex_unlock (&control_mutex);<br>
+<br>
+  // Break here.  At this point the other thread will have the contended_mutex,<br>
+  // and be sitting in its cond_wait for the control condition.  So there is<br>
+  // no way that our by-hand calling of call_me_to_get_lock will proceed<br>
+  // without running the first thread at least somewhat.<br>
+<br>
+  call_me_to_get_lock();<br>
+  pthread_join (thread_1, NULL);<br>
+<br>
+  return 0;<br>
+<br>
+}<br>
<br>
Removed: lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp?rev=245261&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp?rev=245261&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp (original)<br>
+++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.cpp (removed)<br>
@@ -1,80 +0,0 @@<br>
-#include <stdlib.h><br>
-#include <stdio.h><br>
-<br>
-#include <condition_variable><br>
-#include <mutex><br>
-#include <thread><br>
-<br>
-std::mutex contended_mutex;<br>
-std::mutex control_mutex;<br>
-std::mutex thread_started_mutex;<br>
-<br>
-std::unique_lock<std::mutex> *contended_lock = nullptr;<br>
-std::unique_lock<std::mutex> *control_lock = nullptr;<br>
-std::unique_lock<std::mutex> *thread_started_lock = nullptr;<br>
-<br>
-std::condition_variable  control_condition;<br>
-std::condition_variable  thread_started_condition;<br>
-<br>
-// This function runs in a thread.  The locking dance is to make sure that<br>
-// by the time the main thread reaches the pthread_join below, this thread<br>
-// has for sure acquired the contended_mutex.  So then the call_me_to_get_lock<br>
-// function will block trying to get the mutex, and only succeed once it<br>
-// signals this thread, then lets it run to wake up from the cond_wait and<br>
-// release the mutex.<br>
-<br>
-void *<br>
-lock_acquirer_1 ()<br>
-{<br>
-    contended_lock->lock();<br>
-<br>
-    // Grab this mutex, that will ensure that the main thread<br>
-    // is in its cond_wait for it (since that's when it drops the mutex.<br>
-    thread_started_lock->lock();<br>
-    thread_started_lock->unlock();<br>
-<br>
-    // Now signal the main thread that it can continue, we have the contended lock<br>
-    // so the call to call_me_to_get_lock won't make any progress till  this<br>
-    // thread gets a chance to run.<br>
-    control_lock->lock();<br>
-<br>
-    thread_started_condition.notify_all();<br>
-    control_condition.wait(*control_lock);<br>
-<br>
-    return NULL;<br>
-}<br>
-<br>
-int<br>
-call_me_to_get_lock ()<br>
-{<br>
-    control_condition.notify_all();<br>
-    contended_lock->lock();<br>
-    return 567;<br>
-}<br>
-<br>
-int main ()<br>
-{<br>
-    contended_lock = new std::unique_lock<std::mutex>(contended_mutex, std::defer_lock);<br>
-    control_lock = new std::unique_lock<std::mutex>(control_mutex, std::defer_lock);<br>
-    thread_started_lock = new std::unique_lock<std::mutex>(thread_started_mutex, std::defer_lock);<br>
-<br>
-    thread_started_lock->lock();<br>
-<br>
-    std::thread thread_1(lock_acquirer_1);<br>
-<br>
-    thread_started_condition.wait(*thread_started_lock);<br>
-<br>
-    control_lock->lock();<br>
-    control_lock->unlock();<br>
-<br>
-    // Break here.  At this point the other thread will have the contended_mutex,<br>
-    // and be sitting in its cond_wait for the control condition.  So there is<br>
-    // no way that our by-hand calling of call_me_to_get_lock will proceed<br>
-    // without running the first thread at least somewhat.<br>
-<br>
-    call_me_to_get_lock();<br>
-    thread_1.join();<br>
-<br>
-  return 0;<br>
-<br>
-}<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>