How to add breakpoint when thread sanitizer repoorts data-race?

≯℡__Kan透↙ 提交于 2021-02-05 11:24:08

问题


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:


  1. Run the program under GDB, set breakpoints on exit and _exit. On Linux, also set catch syscall exit_group.
  2. 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.
  1. Profit.

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.



来源:https://stackoverflow.com/questions/63964739/how-to-add-breakpoint-when-thread-sanitizer-repoorts-data-race

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!