In ASan, we have __asan_locate_address and __asan_get_alloc_stack, which is used in LLDB/Xcode to show the allocation backtrace for a heap memory object. This patch implements the same for TSan.
Details
- Reviewers
kcc dvyukov zaks.anna - Commits
- rG1187cbd20fe3: [tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query…
rCRT290119: [tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query…
rL290119: [tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query…
Diff Detail
Event Timeline
lib/tsan/rtl/tsan_debugging.cc | ||
---|---|---|
168 | Makes sense. What about going further and adding a TSan version of __asan_locate_address (see asan_debugging.cc), which will "describe" a pointer and return its bounds if known, i.e. having two APIs: __tsan_locate_address(addr) ... returns region name, start address, block size __tsan_get_alloc_stack(addr) ... returns trace, thread ID Does that sound better or worse than having just one __tsan_get_alloc_stack(addr) ... returns trace, thread ID, start address and block size ? | |
181 | Hm. At least on Darwin, GetTid() returns a unique ID for the current boot of the OS. So it's correct even after the thread finished, and even after the process has ended (as long as you don't reboot). Is gettid() on Linux different? I'm already using os_id to "match" threads in TSan reports: If we see the same os_id, we know it's the same thread even when that thread doesn't exist anymore. I'd like not to lose this feature. Does Linux reuse the thread ID soon enough for this to be a problem? If yes, how about we reset the os_id in the ThreadRegistry when a thread ends (for Linux, and keep the value for Darwin)? |
lib/tsan/rtl/tsan_debugging.cc | ||
---|---|---|
168 | tsan_locate_address(addr) ... returns region name, start address, block size sounds better, more orthogonal and some use cases may not need stack/thread | |
181 | Linux reuses PIDs FIFO, but it still reuses them. |
Since the interface is different from asan, it may makes sense to return block begin and size as well. What do you think?