[PATCH] D14862: [tsan] Fix deadlock_detector_stress_test.cc testcase for OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 01:38:32 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, kcc, glider, samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp.

On OS X, we don't have pthread spinlocks, let's just use a regular mutex instead.  Secondly, `pthread_rwlock_t` is much larger (200 bytes), so `char padding_[64 - sizeof(pthread_rwlock_t)]` actually underflows.

http://reviews.llvm.org/D14862

Files:
  test/tsan/deadlock_detector_stress_test.cc

Index: test/tsan/deadlock_detector_stress_test.cc
===================================================================
--- test/tsan/deadlock_detector_stress_test.cc
+++ test/tsan/deadlock_detector_stress_test.cc
@@ -56,6 +56,7 @@
   static bool supports_recursive_lock() { return true; }
 };
 
+#ifndef __APPLE__
 class PthreadSpinLock {
  public:
   PthreadSpinLock() { assert(0 == pthread_spin_init(&mu_, 0)); }
@@ -76,6 +77,9 @@
   pthread_spinlock_t mu_;
   char padding_[64 - sizeof(pthread_spinlock_t)];
 };
+#else
+class PthreadSpinLock : public PthreadMutex { };
+#endif
 
 class PthreadRWLock {
  public:
@@ -95,7 +99,7 @@
 
  private:
   pthread_rwlock_t mu_;
-  char padding_[64 - sizeof(pthread_rwlock_t)];
+  char padding_[256 - sizeof(pthread_rwlock_t)];
 };
 
 class LockTest {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14862.40749.patch
Type: text/x-patch
Size: 793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151120/447ec135/attachment.bin>


More information about the llvm-commits mailing list