Reputation: 1313
Minimum code.cpp
#include <stdexcept>
#include <iostream>
int main() {
try {
throw std::runtime_error("blah");
} catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}
return 0;
}
On WSL Ubuntu 22.04. Compiled with:
clang++-20 -stdlib=libc++ -fsanitize=address -std=c++23 code.cpp
Running it, generates:
blah
=================================================================
==89869==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x7be9594e0040
#0 0x55db012e9a06 in free (/mnt/c/Users/XXX/OneDrive/Desktop/CPP/a+0xcfa06) (BuildId: 86f094d32b8073486e9ac3a7c6a9d0643854ed87)
#1 0x7fb95a39f59b in std::range_error::~range_error() (/lib/x86_64-linux-gnu/libc++abi.so.1+0x2959b) (BuildId: d7d99734f2d87018ea9a00655e07f5ed15b68b04)
#2 0x7fb95a3a18a3 in __cxa_end_catch (/lib/x86_64-linux-gnu/libc++abi.so.1+0x2b8a3) (BuildId: d7d99734f2d87018ea9a00655e07f5ed15b68b04)
#3 0x55db0132f6fd in main (/mnt/c/Users/XXX/OneDrive/Desktop/CPP/a+0x1156fd) (BuildId: 86f094d32b8073486e9ac3a7c6a9d0643854ed87)
#4 0x7fb95a047d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#5 0x7fb95a047e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#6 0x55db01247474 in _start (/mnt/c/Users/XXX/OneDrive/Desktop/CPP/a+0x2d474) (BuildId: 86f094d32b8073486e9ac3a7c6a9d0643854ed87)
0x7be9594e0040 is located 0 bytes inside of 29-byte region [0x7be9594e0040,0x7be9594e005d)
allocated by thread T0 here:
#0 0x55db0132d1fd in operator new(unsigned long) (/mnt/c/Users/XXX/OneDrive/Desktop/CPP/a+0x1131fd) (BuildId: 86f094d32b8073486e9ac3a7c6a9d0643854ed87)
#1 0x7fb95a40e05f in std::runtime_error::runtime_error(char const*) (/lib/x86_64-linux-gnu/libc++.so.1+0x5b05f) (BuildId: 00e94063b8101dfae8b51b968ad9cd5aafda4a15)
#2 0x7fb95a047d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/mnt/c/Users/XXX/OneDrive/Desktop/CPP/a+0xcfa06) (BuildId: 86f094d32b8073486e9ac3a7c6a9d0643854ed87) in free
==89869==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==89869==ABORTING
-stdlib=libc++
is included for std::print()
in the rest of code, removing it does stop alloc-dealloc-mismatch
.
Is there something can be done to prevent alloc-dealloc-mismatch
?
Or this is simply expected for in "development" clang-20
and lib++-20-dev
? and just need to be reported somewhere...
Thanks!
Upvotes: 3
Views: 215