Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate core dump on AddressSanitizer error

I compiled my code like this to enable Asan:

g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer

but it never generates a core dump so that I can later examine the details of the error. How can I generate it?

like image 654
wsy Avatar asked Mar 17 '17 07:03

wsy


1 Answers

You need to set environment variable to request coredumps

export ASAN_OPTIONS=abort_on_error=1

This should really be default but due to historic reasons ASan just exits with non-zero error code instead.

On 64-bit systems you might need to add

export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1

(coredumps are disabled by default there, in fear that they will be too large).

For complete list of flags you can see Asan wiki.

like image 60
yugr Avatar answered Sep 21 '22 06:09

yugr