View Single Post
Old July 20, 2017, 04:49   #5
AndreyB
Scout
 
Join Date: May 2017
Location: Russia
Posts: 26
AndreyB is on a distinguished road
Quote:
Originally Posted by AnonymousHero View Post
UBSAN/ASAN/etc. are even better and much faster -- so fast that you can just run with it full-time without getting extremely annoyed. For example, they'll actually print the problematic source code (assuming debug info) with a little context. Do

Code:
SANITIZE_FLAGS="-fsanitize=undefined -fsanitize=address" ./configure [...]
when configuring. (I *think* I added the support in a place where you have to set it while configuring, it might also be sufficient to just add the SANITIZE_FLAGS bit before "make" on the command line.)
At first this didn't seam to work but then I ran
Code:
make clean
and (after installing two libraries) it compiled. The output from triggering the bug is below.
Code:
z-virt.c:55:2: runtime error: null pointer passed as argument 1, which is declared to never be null
=================================================================
==1837==ERROR: AddressSanitizer: attempting double-free on 0x7f5f1935f800 in thread T0:
    #0 0x7f5f47f4db00 in free (/lib64/libasan.so.3+0xc6b00)
    #1 0x7f5f47c1548c in SDL_FreeSurface (/lib64/libSDL-1.2.so.0+0x2b48c)
    #2 0x78611c in init_windows /home/user/angband/src/main-sdl.c:3402
    #3 0x77d82f in sdl_HandleEvent /home/user/angband/src/main-sdl.c:2524
    #4 0x77e6b5 in Term_xtra_sdl_event /home/user/angband/src/main-sdl.c:2615
    #5 0x77f3db in Term_xtra_sdl /home/user/angband/src/main-sdl.c:2719
    #6 0x722166 in Term_xtra /home/user/angband/src/ui-term.c:433
    #7 0x730c03 in Term_inkey /home/user/angband/src/ui-term.c:2035
    #8 0x69c0b1 in inkey_aux /home/user/angband/src/ui-input.c:78
    #9 0x69c8d1 in inkey_ex /home/user/angband/src/ui-input.c:254
    #10 0x69cae1 in anykey /home/user/angband/src/ui-input.c:289
    #11 0x6c426c in do_cmd_view_map /home/user/angband/src/ui-map.c:794
    #12 0x784346 in Term_view_map_sdl /home/user/angband/src/main-sdl.c:3144
    #13 0x6c401a in do_cmd_view_map /home/user/angband/src/ui-map.c:763
    #14 0x697c89 in textui_process_command /home/user/angband/src/ui-game.c:313
    #15 0x697e02 in textui_get_cmd /home/user/angband/src/ui-game.c:325
    #16 0x698ccf in play_game /home/user/angband/src/ui-game.c:434
    #17 0x7679c4 in main /home/user/angband/src/main.c:524
    #18 0x7f5f45f91400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    #19 0x403769 in _start (/home/user/angband/src/angband+0x403769)

0x7f5f1935f800 is located 0 bytes inside of 4194304-byte region [0x7f5f1935f800,0x7f5f1975f800)
freed by thread T0 here:
    #0 0x7f5f47f4db00 in free (/lib64/libasan.so.3+0xc6b00)
    #1 0x7f5f47c1548c in SDL_FreeSurface (/lib64/libSDL-1.2.so.0+0x2b48c)

previously allocated by thread T0 here:
    #0 0x7f5f47f4e020 in calloc (/lib64/libasan.so.3+0xc7020)
    #1 0x7f5f47c15684 in SDL_CreateRGBSurface (/lib64/libSDL-1.2.so.0+0x2b684)

SUMMARY: AddressSanitizer: double-free (/lib64/libasan.so.3+0xc6b00) in free
==1837==ABORTING
__________________
I like valgrind. it's the biggest timesaver people invented since the invention of the wheel.
UBSan&ASan are even better (no noticeable initialization delay on my machine).
I'm now playing with it on. WARNING: with UBSan&ASan panic saves don't seam to work.
AndreyB is offline   Reply With Quote