C++ how to get the variable(s) by its address

146 views Asked by At

context: I am using thread sanitizer for my program, and it shows my program has data race. I'm 100% sure why (maybe there's too much memory access), thread sanitizer doesn't give out the exact stacktrace for the invalid access. There's only

Previous read of size 4 at 0x7b1800004140 by thread T36:
    [failed to restore the stack]

I have tried to set the history_size=7 when running thread sanitizer according to the doc, but still cannot get the stacktrace.

I know C/C++ supports address randomization due to security concern, so I use -fno-stack-protector to compile my program, which makes the invalid address access the same for multiple times of running.

I want to know how could I get which variable(s) resides on this address, so that I could directly get where am I illegally accessing it?

I use bazel as my build system, which indirectly relies on clang v13.0.0.

0

There are 0 answers