Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitizer error in aizomba.cpp #24

Closed
NY00123 opened this issue Feb 22, 2019 · 2 comments · Fixed by #822
Closed

Sanitizer error in aizomba.cpp #24

NY00123 opened this issue Feb 22, 2019 · 2 comments · Fixed by #822

Comments

@NY00123
Copy link
Collaborator

NY00123 commented Feb 22, 2019

Unfortunately I haven't gotten more details, other than that it has occurred in E1M1 while moving near enemies, I think. (Note that if sdlayer.cpp's line number differs, that's a bit of my fault, and probably shouldn't be related.)

==7659==ERROR: AddressSanitizer: unknown-crash on address 0x555555c731a4 at pc 0x5555557126cb bp 0x7fffffffd8e0 sp 0x7fffffffd8d0
READ of size 52 at 0x555555c731a4 thread T0
    #0 0x5555557126ca in thinkPonder source/blood/src/aizomba.cpp:184
    #1 0x5555556d360a in aiProcessDudes() source/blood/src/ai.cpp:1325
    #2 0x5555556c8d47 in actProcessSprites() source/blood/src/actor.cpp:5398
    #3 0x5555556939ad in ProcessFrame() source/blood/src/blood.cpp:915
    #4 0x555555697367 in app_main source/blood/src/blood.cpp:1666
    #5 0x555555a04353 in main source/build/src/sdlayer.cpp:494
    #6 0x7ffff609309a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #7 0x55555568c309 in _start (/mnt/hdd/Games/nblood/NBlood/nblood+0x138309)

0x555555c731a4 is located 60 bytes to the left of global variable 'xsprite' defined in 'source/blood/src/db.cpp:38:9' (0x555555c731e0) of size 122880
0x555555c731c0 is located 0 bytes to the right of global variable 'xsector' defined in 'source/blood/src/db.cpp:39:9' (0x555555c6b9c0) of size 30720
SUMMARY: AddressSanitizer: unknown-crash source/blood/src/aizomba.cpp:184 in thinkPonder
Shadow bytes around the buggy address:
  0x0aab2ab865e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab865f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0aab2ab86630: 00 00 00 00[00]00 00 00 f9 f9 f9 f9 00 00 00 00
  0x0aab2ab86640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86680: 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==7659==ABORTING```
@NY00123
Copy link
Collaborator Author

NY00123 commented Feb 22, 2019

OK, it looks like I've just reproduced this again, including some more details. (sdlayer.cpp's line number may be different here, too, again due to some unrelated local change of mine.)

screenshot from 2019-02-22 11-30-07

==8819==ERROR: AddressSanitizer: unknown-crash on address 0x555555c731a4 at pc 0x5555557126cb bp 0x7fffffffd8f0 sp 0x7fffffffd8e0
READ of size 52 at 0x555555c731a4 thread T0
    #0 0x5555557126ca in thinkPonder source/blood/src/aizomba.cpp:184
    #1 0x5555556d360a in aiProcessDudes() source/blood/src/ai.cpp:1325
    #2 0x5555556c8d47 in actProcessSprites() source/blood/src/actor.cpp:5398
    #3 0x5555556939ad in ProcessFrame() source/blood/src/blood.cpp:915
    #4 0x555555697367 in app_main source/blood/src/blood.cpp:1666
    #5 0x555555a04353 in main source/build/src/sdlayer.cpp:494
    #6 0x7ffff609309a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #7 0x55555568c309 in _start (/mnt/hdd/Games/nblood/NBlood/nblood+0x138309)

0x555555c731a4 is located 60 bytes to the left of global variable 'xsprite' defined in 'source/blood/src/db.cpp:38:9' (0x555555c731e0) of size 122880
0x555555c731c0 is located 0 bytes to the right of global variable 'xsector' defined in 'source/blood/src/db.cpp:39:9' (0x555555c6b9c0) of size 30720
SUMMARY: AddressSanitizer: unknown-crash source/blood/src/aizomba.cpp:184 in thinkPonder
Shadow bytes around the buggy address:
  0x0aab2ab865e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab865f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0aab2ab86630: 00 00 00 00[00]00 00 00 f9 f9 f9 f9 00 00 00 00
  0x0aab2ab86640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0aab2ab86680: 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==8819==ABORTING

Thread 1 "nblood" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) p pTarget
No symbol "pTarget" in current context.
(gdb) bt
#0  0x00007ffff60b0077 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6091535 in __GI_abort () at abort.c:79
#2  0x00007ffff72e428e in  () at /usr/lib/x86_64-linux-gnu/libasan.so.5
#3  0x00007ffff72ec978 in  () at /usr/lib/x86_64-linux-gnu/libasan.so.5
#4  0x00007ffff72cff35 in  () at /usr/lib/x86_64-linux-gnu/libasan.so.5
#5  0x00007ffff72d1104 in __asan_report_load_n ()
    at /usr/lib/x86_64-linux-gnu/libasan.so.5
#6  0x00005555557126cb in thinkPonder(spritetype*, XSPRITE*)
    (pSprite=0x555555f6ca1c <sprite_s+10076>, pXSprite=0x555555c8ea44 <xsprite+112740>)
    at source/blood/src/aizomba.cpp:178
#7  0x00005555556d360b in aiProcessDudes() () at source/blood/src/ai.cpp:1325
#8  0x00005555556c8d48 in actProcessSprites() () at source/blood/src/actor.cpp:5398
#9  0x00005555556939ae in ProcessFrame() () at source/blood/src/blood.cpp:915
#10 0x0000555555697368 in app_main(int, char const* const*)
    (argc=<optimized out>, argv=<optimized out>) at source/blood/src/blood.cpp:1666
#11 0x0000555555a04354 in main(int, char**) (argc=1, argv=0x7fffffffdfe8)
    at source/build/src/sdlayer.cpp:494
(gdb) up
#1  0x00007ffff6091535 in __GI_abort () at abort.c:79
79	abort.c: No such file or directory.
(gdb) up
#2  0x00007ffff72e428e in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
(gdb) up
#3  0x00007ffff72ec978 in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
(gdb) up
#4  0x00007ffff72cff35 in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
(gdb) up
#5  0x00007ffff72d1104 in __asan_report_load_n ()
   from /usr/lib/x86_64-linux-gnu/libasan.so.5
(gdb) up
#6  0x00005555557126cb in thinkPonder (pSprite=0x555555f6ca1c <sprite_s+10076>, 
    pXSprite=0x555555c8ea44 <xsprite+112740>) at source/blood/src/aizomba.cpp:178
178	    dassert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
(gdb) p pXSprite
$1 = (XSPRITE *) 0x555555c8ea44 <xsprite+112740>
(gdb) p pXTarget
$2 = (XSPRITE *) 0x555555c731a4 <xsector+30692>
(gdb) p xsprite
value requires 122880 bytes, which is more than max-value-size
(gdb) p sizeof(xsprite)/sizeof(*xsprite)
$3 = 2048
(gdb) p sizeof(sector)/sizeof(*xsector)
$4 = 0
(gdb) p sizeof(xsector)/sizeof(*xsector)
$5 = 512
(gdb) p pXSprite->target
$6 = 544
(gdb) p dx
$7 = 1880
(gdb) p dy
$8 = 5361
(gdb) p pXTarget
$9 = (XSPRITE *) 0x555555c731a4 <xsector+30692>
(gdb) p pXTarget->health
$10 = 0

@nukeykt
Copy link
Owner

nukeykt commented Feb 22, 2019

I think for some reason target sprite has no associated XSPRITE structure(i.e pTarget->extra == -1) and game tries to read xsprite[-1].health

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants