I have a custom assert()
-like macro that calls abort()
on failure. When using AddressSanitizer, I would prefer to have the usual nice stack trace printed on assertion failures. How can this be achieved?
abort()
is called?abort()
here?You can use __sanitizer_print_stack_trace
from sanitizer/common_interface_defs.h
:
$ cat tmp.cc
#include <sanitizer/common_interface_defs.h>
int main() {
__sanitizer_print_stack_trace();
return 0;
}
$ g++ tmp.cc -fsanitize=address
$ ./a.out
#0 0x7fe00b381e58 in __sanitizer_print_stack_trace (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xece58)
#1 0x55a059f7f802 in main (/home/yugr/a.out+0x802)
#2 0x7fe00aec5b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#3 0x55a059f7f719 in _start (/home/yugr/a.out+0x719)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With