d2640462cb
Descent 2 has a hack, present as far back as I can trace, that suppresses starting sounds during level load. The original reason was not recorded, but this hack has the useful side effect that it avoids using uninitialized data when set_sound_sources tries to use a Viewer that has not been reset for the objects of the new level. Descent 1 lacks this hack, so an invalid Viewer is used, which may trigger a valptridx trap if the undefined data has an invalid segment number, and could cause memory corruption in builds which do not validate the segment index. The valptridx trap: ``` terminate called after throwing an instance of 'valptridx<dcx::segment>::index_range_exception' what(): similar/main/digiobj.cpp:389: invalid index used in array subscript: base=(nil) size=9000 index=65021 ``` The backtrace leading to the trap: ``` d1x::digi_link_sound_common (viewer=..., so=..., pos=..., forever=<optimized out>, max_volume=<optimized out>, max_distance=..., soundnum=42, segnum=...) at similar/main/digiobj.cpp:389 0x00005555555a4e2d in d1x::digi_link_sound_to_pos2 (vcobjptr=..., max_distance=..., max_volume=32768, forever=1, pos=..., sidenum=4, segnum=..., org_soundnum=121) at similar/main/digiobj.cpp:483 d1x::digi_link_sound_to_pos (soundnum=soundnum@entry=121, segnum=..., sidenum=sidenum@entry=4, pos=..., forever=forever@entry=1, max_volume=32768) at similar/main/digiobj.cpp:490 0x00005555555c140d in d1x::set_sound_sources (vcsegptridx=..., vcvertptr=...) at similar/main/gameseq.cpp:817 d1x::LoadLevel (level_num=<optimized out>, page_in_textures=1) at similar/main/gameseq.cpp:1022 0x00005555555c2654 in d1x::StartNewLevelSub (level_num=-1, page_in_textures=<optimized out>) at similar/main/gameseq.cpp:1865 ``` Backport this hack into Descent 1. Ultimately, the hack should go away and data should be loaded in an order that does not access undefined memory. Reported-by: Spacecpp <https://github.com/dxx-rebirth/dxx-rebirth/issues/463> |
||
---|---|---|
.. | ||
2d | ||
3d | ||
arch | ||
editor | ||
include | ||
main | ||
maths | ||
mem | ||
misc | ||
music | ||
texmap | ||
ui | ||
unittest |