|
$ make lib-gcc-asan && make bin-gcc-preload |
|
g++-4.9 -fno-omit-frame-pointer -fsanitize=address -std=c++11 my.cpp -o libmy.so -shared -fPIC -g3 |
|
g++-4.9 -std=c++11 -c -I. main.cpp -O -g3 -o main.o -DDYNAMIC |
|
g++-4.9 -o main-gcc-preload main.o -L. -ldl -lmy |
|
LD_LIBRARY_PATH=. ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.1 ./main-gcc-preload |
|
DYNAMIC option |
|
Loading symbol 'sayHi'... |
|
================================================================= |
|
==5698==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffc22f72144 at pc 0x7f39afaf784f bp 0x7ffc22f71f70 sp 0x7ffc22f71f68 |
|
READ of size 4 at 0x7ffc22f72144 thread T0 |
|
#0 0x7f39afaf784e in sayHi /home/menato/Work/tmp/my.cpp:6 |
|
#1 0x400ad6 in main /home/menato/Work/tmp/main.cpp:40 |
|
#2 0x7f39b275c82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) |
|
#3 0x400928 in _start (/home/menato/Work/tmp/main-gcc-preload+0x400928) |
|
|
|
Address 0x7ffc22f72144 is located in stack of thread T0 at offset 436 in frame |
|
#0 0x7f39afaf777f in sayHi /home/menato/Work/tmp/my.cpp:3 |
|
|
|
This frame has 1 object(s): |
|
[32, 432) 'array_at_libmy' <== 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/menato/Work/tmp/my.cpp:6 sayHi |
|
Shadow bytes around the buggy address: |
|
0x1000045e63d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e63e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e63f0: 00 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
=>0x1000045e6420: 00 00 00 00 00 00 00 00[f4]f4 f3 f3 f3 f3 00 00 |
|
0x1000045e6430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
|
0x1000045e6470: 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 |
|
Contiguous container OOB:fc |
|
ASan internal: fe |
|
==5698==ABORTING |
|
Makefile:35: recipe for target 'bin-gcc-preload' failed |
|
make: *** [bin-gcc-preload] Error 1 |