Weird stack underflow after 08be24993e #407

Open
opened 2024-11-14 13:55:34 +00:00 by SanyaSho · 0 comments
SanyaSho commented 2024-11-14 13:55:34 +00:00 (Migrated from gitlab.com)

https://gitlab.com/leaknet/LeakNet/-/blob/rewrite/engine/l_studio.cpp?ref_type=heads#L123

This probably happens because engine is trying to load model which is not exists

ASAN log after map d1_trainstation_02:

==13703==ERROR: AddressSanitizer: stack-buffer-underflow on address 0xfffec3ef at pc 0xf1d43446 bp 0xfffebdd8 sp 0xfffebdc8
READ of size 2 at 0xfffec3ef thread T0
    #0 0xf1d43445 in mstudioseqdesc_t::anim(int, int) const /home/sanyasho/src/LeakNet/public/studio.h:428
    #1 0xf1d387eb in Mod_LoadStudioModel(model_t*, void*, bool) /home/sanyasho/src/LeakNet/engine/l_studio.cpp:123
    #2 0xf1d604e0 in CModelLoader::Studio_LoadModel(model_t*, void*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:3206
    #3 0xf1d59e97 in CModelLoader::LoadModel(model_t*, IModelLoader::REFERENCETYPE*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2254
    #4 0xf1d5960d in CModelLoader::GetModelForName(char const*, IModelLoader::REFERENCETYPE) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2145
    #5 0xf1da8ba6 in CStaticPropMgr::UnserializeModelDict(CUtlBuffer&) /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:972
    #6 0xf1da987c in CStaticPropMgr::UnserializeStaticProps() /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:1077
    #7 0xf1da9aac in CStaticPropMgr::LevelInit() /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:1098
    #8 0xf1e0e29c in SV_ClearWorld() /home/sanyasho/src/LeakNet/engine/world.cpp:94
    #9 0xf1ddcf40 in SV_SpawnServer(char const*, char const*) /home/sanyasho/src/LeakNet/engine/sv_main.cpp:4496
    #10 0xf1d2493d in Host_NewGame(char*, bool, bool) /home/sanyasho/src/LeakNet/engine/host.cpp:2121
    #11 0xf1d3430c in CHostState::State_NewGame() /home/sanyasho/src/LeakNet/engine/host_state.cpp:226
    #12 0xf1d34da6 in CHostState::FrameUpdate(float, int) /home/sanyasho/src/LeakNet/engine/host_state.cpp:417
    #13 0xf1d337a0 in HostState_Frame(float, int) /home/sanyasho/src/LeakNet/engine/host_state.cpp:80
    #14 0xf1df810e in CEngine::Frame() /home/sanyasho/src/LeakNet/engine/sys_engine.cpp:202
    #15 0xf1df72e5 in CDedicatedServerAPI::RunFrame() /home/sanyasho/src/LeakNet/engine/sys_dll2.cpp:510
    #16 0x5657aa00 in main /home/sanyasho/src/LeakNet/dedicated/sys_linux.cpp:563
    #17 0xf75b8bd6  (/usr/lib32/libc.so.6+0x20bd6) (BuildId: 7d4c1772ffaf5490295c0ec5c5b1231fcd545432)
    #18 0xf75b8c9c in __libc_start_main (/usr/lib32/libc.so.6+0x20c9c) (BuildId: 7d4c1772ffaf5490295c0ec5c5b1231fcd545432)
    #19 0x565584c6 in _start (/home/sanyasho/src/LeakNet/leaknet-install/bin/hlds_linux+0x34c6) (BuildId: a68aeb824f4e0c175f9b7489981e190f1181a05f)

Address 0xfffec3ef is located in stack of thread T0 at offset 31 in frame
    #0 0xf1d59701 in CModelLoader::LoadModel(model_t*, IModelLoader::REFERENCETYPE*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2172

  This frame has 1 object(s):
    [32, 65568) 'stackbuf' (line 2175) <== Memory access at offset 31 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-underflow /home/sanyasho/src/LeakNet/public/studio.h:428 in mstudioseqdesc_t::anim(int, int) const
Shadow bytes around the buggy address:
  0xfffec100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0xfffec380: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1[f1]00 00
  0xfffec400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0xfffec600: 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
==13703==ABORTING```
https://gitlab.com/leaknet/LeakNet/-/blob/rewrite/engine/l_studio.cpp?ref_type=heads#L123 This probably happens because engine is trying to load model which is not exists ASAN log after `map d1_trainstation_02`: ```================================================================= ==13703==ERROR: AddressSanitizer: stack-buffer-underflow on address 0xfffec3ef at pc 0xf1d43446 bp 0xfffebdd8 sp 0xfffebdc8 READ of size 2 at 0xfffec3ef thread T0 #0 0xf1d43445 in mstudioseqdesc_t::anim(int, int) const /home/sanyasho/src/LeakNet/public/studio.h:428 #1 0xf1d387eb in Mod_LoadStudioModel(model_t*, void*, bool) /home/sanyasho/src/LeakNet/engine/l_studio.cpp:123 #2 0xf1d604e0 in CModelLoader::Studio_LoadModel(model_t*, void*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:3206 #3 0xf1d59e97 in CModelLoader::LoadModel(model_t*, IModelLoader::REFERENCETYPE*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2254 #4 0xf1d5960d in CModelLoader::GetModelForName(char const*, IModelLoader::REFERENCETYPE) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2145 #5 0xf1da8ba6 in CStaticPropMgr::UnserializeModelDict(CUtlBuffer&) /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:972 #6 0xf1da987c in CStaticPropMgr::UnserializeStaticProps() /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:1077 #7 0xf1da9aac in CStaticPropMgr::LevelInit() /home/sanyasho/src/LeakNet/engine/staticpropmgr.cpp:1098 #8 0xf1e0e29c in SV_ClearWorld() /home/sanyasho/src/LeakNet/engine/world.cpp:94 #9 0xf1ddcf40 in SV_SpawnServer(char const*, char const*) /home/sanyasho/src/LeakNet/engine/sv_main.cpp:4496 #10 0xf1d2493d in Host_NewGame(char*, bool, bool) /home/sanyasho/src/LeakNet/engine/host.cpp:2121 #11 0xf1d3430c in CHostState::State_NewGame() /home/sanyasho/src/LeakNet/engine/host_state.cpp:226 #12 0xf1d34da6 in CHostState::FrameUpdate(float, int) /home/sanyasho/src/LeakNet/engine/host_state.cpp:417 #13 0xf1d337a0 in HostState_Frame(float, int) /home/sanyasho/src/LeakNet/engine/host_state.cpp:80 #14 0xf1df810e in CEngine::Frame() /home/sanyasho/src/LeakNet/engine/sys_engine.cpp:202 #15 0xf1df72e5 in CDedicatedServerAPI::RunFrame() /home/sanyasho/src/LeakNet/engine/sys_dll2.cpp:510 #16 0x5657aa00 in main /home/sanyasho/src/LeakNet/dedicated/sys_linux.cpp:563 #17 0xf75b8bd6 (/usr/lib32/libc.so.6+0x20bd6) (BuildId: 7d4c1772ffaf5490295c0ec5c5b1231fcd545432) #18 0xf75b8c9c in __libc_start_main (/usr/lib32/libc.so.6+0x20c9c) (BuildId: 7d4c1772ffaf5490295c0ec5c5b1231fcd545432) #19 0x565584c6 in _start (/home/sanyasho/src/LeakNet/leaknet-install/bin/hlds_linux+0x34c6) (BuildId: a68aeb824f4e0c175f9b7489981e190f1181a05f) Address 0xfffec3ef is located in stack of thread T0 at offset 31 in frame #0 0xf1d59701 in CModelLoader::LoadModel(model_t*, IModelLoader::REFERENCETYPE*) /home/sanyasho/src/LeakNet/engine/modelloader.cpp:2172 This frame has 1 object(s): [32, 65568) 'stackbuf' (line 2175) <== Memory access at offset 31 partially underflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-underflow /home/sanyasho/src/LeakNet/public/studio.h:428 in mstudioseqdesc_t::anim(int, int) const Shadow bytes around the buggy address: 0xfffec100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0xfffec380: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1[f1]00 00 0xfffec400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0xfffec600: 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 ==13703==ABORTING```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Archive/LeakNet#407
No description provided.