[clang] [compiler-rt] [llvm] [tsan] Add simulation to TSAN (PR #183200)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 23:02:40 PST 2026


================
@@ -84,6 +84,15 @@ inline bool MustIgnoreInterceptor(ThreadState *thr) {
   if (MustIgnoreInterceptor(thr))            \
     return REAL(func)(__VA_ARGS__);
 
+// Mark an interceptor as unsupported during simulation. If simulation is
+// active, reports an error but continues with normal TSAN instrumentation.
+// The simulation will return an error at the end of the current iteration.
+#define SIMULATE_CHECK_UNSUPPORTED(func) \
+  if (UNLIKELY(SimulateIsActive())) {    \
+    SimulateReportUnsupported(#func);    \
+    return {};                           \
----------------
vitalybuka wrote:

Returning 0 here contradicts the comment above and pretends locks or waits succeeded. For example, pthread_cond_timedwait returning 0 without yielding will spin forever in a wait loop, and pthread_mutex_timedlock returning 0 without locking will corrupt state on pthread_mutex_unlock.

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


More information about the cfe-commits mailing list