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

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 14 01:52:53 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:

If there is no synchronization, then the order does not matter.

I think we only need to enforce different orderings of synchronization operations in threads.
For normal operations (mem accesses, cond_destroy, etc) ordering does not matter (provided order of sync operations is the same). They either race (in detectable way), or does not, regardless of the order.

It would be useful to figure out the general rule, and explain it in a comment somewhere. E.g. "we generally add delays before sync operaitons b/c of ...".


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


More information about the llvm-commits mailing list