How to add breakpoint when thread sanitizer repoorts data-race?
问题 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 don't work either. 回答1: Run the program under GDB, set breakpoints on exit and _exit . On Linux, also set catch syscall exit_group . set 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.