线程清理程序拒绝数据争用时如何添加断点?

问题描述

地址清理器也有类似的问题,但是对于线程清理器,它不起作用,我试图中断__sanitizer_print_stack_trace,该方法也不起作用。

解决方法

  1. 在GDB下运行程序,在exit_exit上设置断点。在Linux上,还要设置catch syscall exit_group
  2. halt_on_error=1中设置TSAN_OPTIONS,要求线程消毒剂进入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. 利润。

P.S。当达到断点时,使用GDB where命令查看如何报告错误。即使未设置__tsan_report_error,也可以在堆栈上可能存在的某种halt_on_error上设置断点。