[compiler-rt] [asan] Make frame number checks more flexable (PR #94307)

Hau Hsu via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 03:25:02 PDT 2024


hau-hsu wrote:

> Do you have guess why this you have this issue and we don't?

I forgot to mention, this happens on RISC-V target.
I was testing the for #66743 on RISC-V Qemu (system mode).

The stack trace in the previous comment:
```
previously allocated by thread T0 here:
    #0 0x2aaeb3662a in operator[] /home/root/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:68:3
    #1 0x2aaeb3662a in GetSizeClass /home/root/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_primary32.h:203:44
    #2 0x2aaeb3662a in PointerIsMine /home/root/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_primary32.h:198:12
    #3 0x2aaeb3662a in FromPrimary /home/root/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_combined.h:121:59
    #4 0x2aaeb3662a in Allocate /home/root/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_dlsym.h:36:5
    #5 0x2aaeb3662a in malloc /home/root/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:12
    #6 0x3fb7319a0a  (<unknown module>)
    #7 0x2aaeb6e996 in main /home/root/llvm-project/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cpp:33:13
    #8 0x3fb770dd74  (/lib/libc.so.6+0x29d74)
```
stack 0~5 have the same PC, and are inlined functions.

I compared the executable and dwarf between RISC-V and X86, found that `Allocate` is inlined in RISC-V but not in X86:
https://github.com/llvm/llvm-project/blob/638d96843893f6981c9af8c501f6999cc7db15e6/compiler-rt/lib/asan/asan_malloc_linux.cpp#L65-L70

Thus the stack trace looks different. This happens in several test cases. So I created this PR.

https://github.com/llvm/llvm-project/pull/94307


More information about the llvm-commits mailing list