当线程清理程序报告数据争用时如何添加断点?

pre*_*uin 4 gcc gdb thread-sanitizer

对于地址清理程序也有类似的问题,但对于线程清理程序,它不起作用,我尝试中断 __sanitizer_print_stack_trace,但它也不起作用。

Emp*_*ian 5

  1. 在GDB下运行程序,在exit和处设置断点_exit。在 Linux 上,还设置catch syscall exit_group.
  2. 设置halt_on_error=1TSAN_OPTIONS要求线程清理程序在出现第一个错误时退出
(gdb) set env TSAN_OPTIONS=halt_on_error=1
(gdb) run
... error should be reported and one of the breakpoints should fire.
Run Code Online (Sandbox Code Playgroud)
  1. 利润。

PS 断点时,使用GDBwhere命令查看如何报错。即使没有设置,在堆栈上可能存在的某种断点上设置断点__tsan_report_error也可能起作用halt_on_error