[compiler-rt] [SanitizerCommon] add null check for fopen64 interceptor (PR #68760)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 21:34:33 PDT 2023


thurstond wrote:


After adding back the 'RUN' command but not making the interceptor change:
```
==2130402==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000 (pc 0x566e2bb0 bp 0xff8ee478 sp 0xff8ee02c T0)
==2130402==The signal is caused by a READ memory access.
==2130402==Hint: address points to the zero page.
    #0 0x566e2bb0 in __sanitizer::internal_strlen(char const*) /usr/local/google/home/thurston/llvm-projectC/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp:176:10
    #1 0x566894cc in fopen64 /usr/local/google/home/thurston/llvm-projectC/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6148:3
    #2 0x5670d2c4 in main /usr/local/google/home/thurston/llvm-projectC/compiler-rt/test/sanitizer_common/TestCases/fopen64_nullptr.c:8:18
    #3 0xf7c237c4  (/lib/i386-linux-gnu/libc.so.6+0x237c4) (BuildId: a098c9624e774a2b27e7cc84a9bb6290f93d26c4)
    #4 0xf7c23887 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x23887) (BuildId: a098c9624e774a2b27e7cc84a9bb6290f93d26c4)
    #5 0x56623346 in _start (/usr/local/google/home/thurston/llvm-projectC/build/projects/compiler-rt/test/sanitizer_common/asan-i386-Linux/Output/fopen64_nullptr.c.tmp+0x19346)
```
This is good: your test resulted in a failure when the interceptor code is wrong

After also making the interceptor change:
```
clang: error: unsupported option '-fsanitize=hwaddress' for target 'i386-unknown-linux-gnu'
...
clang: error: unsupported option '-fsanitize=thread' for target 'i386-unknown-linux-gnu'
...
/usr/bin/ld: cannot find /usr/local/google/home/thurston/llvm-projectC/build/lib/clang/18/lib/linux/libclang_rt.msan-i386.a: No such file or directory
...
Failed Tests (3):
  SanitizerCommon-hwasan-x86_64-Linux :: fopen64_nullptr.c
  SanitizerCommon-msan-x86_64-Linux :: fopen64_nullptr.c
  SanitizerCommon-tsan-x86_64-Linux :: fopen64_nullptr.c


Testing Time: 0.33s
  Excluded: 1989
  Passed  :    6
  Failed  :    3
```
so I think it also needs something like:
```
// UNSUPPORTED: hwasan, msan, tsan
```
or you could try changing the compilation options to remove the 32-bit build (haven't tried it myself).

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


More information about the llvm-commits mailing list