There is a similar question for address sanitizers, but for thread sanitizers, it doesn't work, I have tried to break on __sanitizer_print_stack_trace, which doesn't work either.
exit
and _exit
. On Linux, also set catch syscall exit_group
.halt_on_error=1
in TSAN_OPTIONS
to ask thread sanitizer to exit on first error:(gdb) set env TSAN_OPTIONS=halt_on_error=1
(gdb) run
... error should be reported and one of the breakpoints should fire.
P.S. When the breakpoint is hit, use GDB where
command to see how the error is reported. Setting a breakpoint on some kind of __tsan_report_error
that is likely on the stack will probably work even without setting halt_on_error
.