[clang] [compiler-rt] [tsan] Add simulation to TSAN (PR #183200)
Chris Cotter via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 26 21:08:12 PDT 2026
================
----------------
ccotter wrote:
If I understand what you are saying, you are suggesting is to have hooks in compiler-rt's TSAN rtl, which by default are `nullptr` and do nothing. And, another library would install hooks that do the simulation (pausing, etc)
```
// rtl/tsan_interface_atomic.cpp:
// some header
typedef void (*__tsan_schedule_hook_t)(int sync_kind, /* other args are probably needed for pthread_mutex ops */);
void __tsan_set_schedule_hook(__tsan_schedule_hook_t hook);
extern __tsan_schedule_hook_t schedule_hook;
...
ALWAYS_INLINE auto AtomicImpl(morder mo, Types... args) {
if (schedule_hook)
schedule_hook(TSAN_SYNC_ATOMIC);
// ... existing logic
}
```
And, the thread simulation fuzzer library would call `__tsan_schedule_hook_t`? Would we want a new fuzzer library, or package this with libfuzzer (I assume a separate one from libfuzzer). How would this interact with GCC's TSAN (which I'm also interested in longer term)? Presumably GCC would need to create and expose that new library as well? The approach I've taken here is convenient since it does not introduce a new library (just pointing out).
Let me know if I misunderstand. I would like @dvyukov's thoughts on this before I make changes, but I think this makes sense.
https://github.com/llvm/llvm-project/pull/183200
More information about the cfe-commits
mailing list