[compiler-rt] r180782 - tsan: fix deadlock detector table (OK to lock sync var mutex during reporting)
Dmitry Vyukov
dvyukov at google.com
Tue Apr 30 05:00:40 PDT 2013
Author: dvyukov
Date: Tue Apr 30 07:00:40 2013
New Revision: 180782
URL: http://llvm.org/viewvc/llvm-project?rev=180782&view=rev
Log:
tsan: fix deadlock detector table (OK to lock sync var mutex during reporting)
Added:
compiler-rt/trunk/lib/tsan/lit_tests/mutexset8.cc
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc
Added: compiler-rt/trunk/lib/tsan/lit_tests/mutexset8.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/mutexset8.cc?rev=180782&view=auto
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/mutexset8.cc (added)
+++ compiler-rt/trunk/lib/tsan/lit_tests/mutexset8.cc Tue Apr 30 07:00:40 2013
@@ -0,0 +1,39 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int Global;
+pthread_mutex_t *mtx;
+
+void *Thread1(void *x) {
+ sleep(1);
+ pthread_mutex_lock(mtx);
+ Global++;
+ pthread_mutex_unlock(mtx);
+ return NULL;
+}
+
+void *Thread2(void *x) {
+ Global--;
+ return NULL;
+}
+
+int main() {
+ // CHECK: WARNING: ThreadSanitizer: data race
+ // CHECK: Write of size 4 at {{.*}} by thread T1
+ // CHECK: (mutexes: write [[M1:M[0-9]+]]):
+ // CHECK: Previous write of size 4 at {{.*}} by thread T2:
+ // CHECK: Mutex [[M1]] created at:
+ // CHECK: #0 pthread_mutex_init
+ // CHECK: #1 main {{.*}}/mutexset8.cc
+ mtx = new pthread_mutex_t;
+ pthread_mutex_init(mtx, 0);
+ pthread_t t[2];
+ pthread_create(&t[0], NULL, Thread1, NULL);
+ pthread_create(&t[1], NULL, Thread2, NULL);
+ pthread_join(t[0], NULL);
+ pthread_join(t[1], NULL);
+ pthread_mutex_destroy(mtx);
+ delete mtx;
+}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc?rev=180782&r1=180781&r2=180782&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc Tue Apr 30 07:00:40 2013
@@ -31,8 +31,8 @@ static MutexType CanLockTab[MutexTypeCou
/*0 MutexTypeInvalid*/ {},
/*1 MutexTypeTrace*/ {MutexTypeLeaf},
/*2 MutexTypeThreads*/ {MutexTypeReport},
- /*3 MutexTypeReport*/ {MutexTypeSyncTab, MutexTypeMBlock,
- MutexTypeJavaMBlock},
+ /*3 MutexTypeReport*/ {MutexTypeSyncTab, MutexTypeSyncVar,
+ MutexTypeMBlock, MutexTypeJavaMBlock},
/*4 MutexTypeSyncVar*/ {},
/*5 MutexTypeSyncTab*/ {MutexTypeSyncVar},
/*6 MutexTypeSlab*/ {MutexTypeLeaf},
More information about the llvm-commits
mailing list