Incompatibility Between AddressSanitizer and libc++
bingit
jhbpeter at gmail.com
Tue Mar 12 02:22:11 GMT 2024
Hello, I am Bin, thanks for your contribution to deliver to developers one of the most innovative compilers.
I have encountered a alloc/dealloc mismatch while running a simple demo about exception handling, using clang 18 and libc++
which are installed following the instruction on https://apt.llvm.org/. I spent some time inspecting the assembly code of the
demo program, libc++ and libc++abi, it turns out:
1. While initializing an instance of std::runtime_error, an internal string was allocated on the heap with the new operator which is provided by
AddressSanitizer and located in the main module. So the memory was tracked.
2. During the last step of handling the exception, the exception was released by std::runtime_error::~runtime_error in libc++abi.so.1. However,
the memory for the string was released by calling the statically linked delete operator (not the one implemented by ASan, and it called Asan’s
free function. Consequently, a mismatch between allocation and deallocation was detected.
3. I have post more details on https://github.com/llvm/llvm-project/issues/59432#issuecomment-1988788696
I am a compiler love, and I would like to offer some, so feel free to contact me.
Regards, Bin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-llvm-team/attachments/20240312/80f40e69/attachment-0001.htm>
More information about the Pkg-llvm-team
mailing list