[compiler-rt] [llvm] [tsan] Introduce Adaptive Delay Scheduling to TSAN (PR #178836)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 15 02:06:20 PST 2026


================
@@ -1371,20 +1383,23 @@ INTERCEPTOR(int, pthread_cond_signal, void *c) {
   void *cond = init_cond(c);
   SCOPED_TSAN_INTERCEPTOR(pthread_cond_signal, cond);
   MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
+  GetFuzzingScheduler().MutexCvOp();
   return REAL(pthread_cond_signal)(cond);
 }
 
 INTERCEPTOR(int, pthread_cond_broadcast, void *c) {
   void *cond = init_cond(c);
   SCOPED_TSAN_INTERCEPTOR(pthread_cond_broadcast, cond);
   MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), false);
+  GetFuzzingScheduler().MutexCvOp();
   return REAL(pthread_cond_broadcast)(cond);
 }
 
 INTERCEPTOR(int, pthread_cond_destroy, void *c) {
   void *cond = init_cond(c);
   SCOPED_TSAN_INTERCEPTOR(pthread_cond_destroy, cond);
   MemoryAccessRange(thr, pc, (uptr)c, sizeof(uptr), true);
+  GetFuzzingScheduler().MutexCvOp();
----------------
dvyukov wrote:

Do you mean this example?

```
std::atomic_int d;
2 int a;
3 int main()
4 {
5 std::thread t1([]() { ++d; ++a; ++d; });
6 std::thread t2([]() { ++d; ++a; ++d; });
7 t1.join(); t2.join();
8 std::cout << d << a << std::endl;
9 }
```

Isn't enough to emit delay only before the second `++d` in each thread to detect the race? And we do emit delays before sync operations for that reason.



https://github.com/llvm/llvm-project/pull/178836


More information about the llvm-commits mailing list