|
$ make using-clang |
|
clang -o main-clang -x c++ -O -g -fsanitize=address main.cpp && \ |
|
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer ./main-clang |
|
================================================================= |
|
==25497==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffaeb43014 at pc 0x4b7453 bp 0x7fffaeb42e50 sp 0x7fffaeb42e48 |
|
READ of size 4 at 0x7fffaeb43014 thread T0 |
|
#0 0x4b7452 in main /home/kkleine/Development/asan-test/main.cpp:5 |
|
#1 0x2af489d27ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 |
|
#2 0x4b720c in _start (/home/kkleine/Development/asan-test/main-clang+0x4b720c) |
|
|
|
Address 0x7fffaeb43014 is located in stack of thread T0 at offset 436 in frame |
|
#0 0x4b72ef in main /home/kkleine/Development/asan-test/main.cpp:2 |
|
|
|
This frame has 1 object(s): |
|
[32, 432) 'stack_array' <== Memory access at offset 436 overflows this variable |
|
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext |
|
(longjmp and C++ exceptions *are* supported) |
|
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/kkleine/Development/asan-test/main.cpp:5 main |
|
Shadow bytes around the buggy address: |
|
0x100075d605b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d605c0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 |
|
0x100075d605d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d605e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d605f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
=>0x100075d60600: 00 00[f3]f3 f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 |
|
0x100075d60610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d60620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d60630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d60640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x100075d60650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
Shadow byte legend (one shadow byte represents 8 application bytes): |
|
Addressable: 00 |
|
Partially addressable: 01 02 03 04 05 06 07 |
|
Heap left redzone: fa |
|
Heap right redzone: fb |
|
Freed heap region: fd |
|
Stack left redzone: f1 |
|
Stack mid redzone: f2 |
|
Stack right redzone: f3 |
|
Stack partial redzone: f4 |
|
Stack after return: f5 |
|
Stack use after scope: f8 |
|
Global redzone: f9 |
|
Global init order: f6 |
|
Poisoned by user: f7 |
|
Container overflow: fc |
|
ASan internal: fe |
|
==25497==ABORTING |
|
make: *** [using-clang] Error 1 |
always use -fsanitize=address https://groups.google.com/g/address-sanitizer/c/SD590XDinfQ/m/NMUPj_G0BgAJ?pli=1 (you are using a internal flags)