[compiler-rt] r260564 - [LSan] Test case fix: mode debug output, synchronization instead of sleep().

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 11:03:09 PST 2016


Author: samsonov
Date: Thu Feb 11 13:03:09 2016
New Revision: 260564

URL: http://llvm.org/viewvc/llvm-project?rev=260564&view=rev
Log:
[LSan] Test case fix: mode debug output, synchronization instead of sleep().

Modified:
    compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc

Modified: compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc?rev=260564&r1=260563&r2=260564&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc Thu Feb 11 13:03:09 2016
@@ -4,12 +4,19 @@
 // RUN: LSAN_OPTIONS="log_pointers=1:log_threads=1" %run %t
 #include <assert.h>
 #include <pthread.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
+
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+bool flag = false;
 
 void *func(void *arg) {
-  sleep(1);
+  // This mutex will never be grabbed.
+  fprintf(stderr, "entered func()\n");
+  pthread_mutex_lock(&mutex);
   free(arg);
+  pthread_mutex_unlock(&mutex);
   return 0;
 }
 
@@ -22,6 +29,8 @@ void create_detached_thread() {
 
   void *arg = malloc(1337);
   assert(arg);
+  // This mutex is never unlocked by the main thread.
+  pthread_mutex_lock(&mutex);
   int res = pthread_create(&thread_id, &attr, func, arg);
   assert(res == 0);
 }




More information about the llvm-commits mailing list