Address Sanitizer:查找导致崩溃的线程

时间:2019-07-18 11:46:24

标签: address-sanitizer

我正在编写崩溃的多线程程序。从下面的AddressSanitizer输出中可以看到,AddressSanitizer将线程ID打印为T16777215,它与pthread_self()gettid()输出不匹配。知道T16777215是什么吗?

==6363== ERROR: AddressSanitizer: heap-use-after-free on address 0x600800021c98 
at pc 0x7f79415f2b95 bp 0x7f79465d66e0 sp 0x7f79465d5e88 
WRITE of size 8 at 0x600800021c98 thread T16777215

#0 0x7f79415f2b94 (/usr/lib64/libasan.so.0.0.0+0xeb94)

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

Asan的线程ID只是线程的序列号:

u32 ThreadRegistry::CreateThread(uptr user_id, bool detached, u32 parent_tid,
                                 void *arg) {
  ...
  } else if (n_contexts_ < max_threads_) {
    // Allocate new thread context and tid.
    tid = n_contexts_++;

(有关完整代码,请参见here)。