Issue |
138982
|
Summary |
[clang] lsan is ignored when used ubsan
|
Labels |
clang
|
Assignees |
|
Reporter |
jonathanpoelen
|
https://godbolt.org/z/dcj4hh73h
With the following code, which has a memory leak:
```cpp
#include <stdio.h>
int main(int argc, char** argv) {
int* a = new int[10];
a[5] = 0;
volatile int b = a[argc];
if (b)
printf("xx\n");
// bool bb = *reinterpret_cast<bool*>(argv); // ubsan ok
// if (bb)
// printf("xx\n");
return 0;
}
```
Compiling with `-fsanitize=address,undefined` does not detect the memory leak, whereas it is detected with `-fsanitize=address` or `-fsanitize=leak` alone.
Furthermore, compiling with `-fsanitize=leak,undefined` gives link errors which are magically fixed by adding `-fsanitize=address` or `-lubsan`:
```sh
/usr/bin/ld: /home/jonathan/rawdisk/test-c09389.o: in function `main':
test.cpp:(.text+0x53): undefined reference to `__ubsan_handle_type_mismatch_v1'
/usr/bin/ld: test.cpp:(.text+0xa7): undefined reference to `__ubsan_handle_pointer_overflow'
/usr/bin/ld: test.cpp:(.text+0xd3): undefined reference to `__ubsan_handle_type_mismatch_v1'
/usr/bin/ld: test.cpp:(.text+0x140): undefined reference to `__ubsan_handle_pointer_overflow'
/usr/bin/ld: test.cpp:(.text+0x16c): undefined reference to `__ubsan_handle_type_mismatch_v1
```
clang version 19.1.7
```
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/14.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.3.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs