omf2097 / openomf

One Must Fall 2097 Remake
http://www.openomf.org
MIT License
362 stars 35 forks source link

OpenOMF is unstable after latest SDL_Mixer merges (segfaults) #498

Closed joyrider3774 closed 7 months ago

joyrider3774 commented 7 months ago

Hi,

during testing and creating a build for my RG35XX plus handheld i noticed openomf was very unstable. It kept segfaulting. I also saw a big change related to SDL2_mixer was done recently, and when i build a version of openomf just before these merged changes (https://github.com/omf2097/openomf/commit/4287067184d9f16d02035f6cf0abcafb0f9755be) the game was no longer unstable. I observed this on both ARM and X86_64 archictecture (debian running under wsl2)

Now it is not very hard to get it to crash so could be easily debugged. Just start the demo mode and wait till the cpu players play in the desert like arena. When those airplaines arive (at least i think it are airplaines) and they fire their bombs its a garantueed crash every time. It also happens on other locations in the game, but this specific one i could easily pinpoint.

I also have stacktraces of these crashes happening from gdb but not sure if they are helpfull

[    211][D] object_set_custom_string(): Set animation string to A5
[    212][D] object_set_custom_string(): Set animation string to A5
[    213][D] object_set_custom_string(): Set animation string to A5
[    222][D] queue_tactic(): HAR 4 queued tactic: CLOSE
[    223][D] match_move(): matched move 35 with string P656
[    235][D] object_set_custom_string(): Set animation string to A5
[    236][D] har_take_damage(): applying 18432.000000 stun damage to 35261.218750
[    236][D] object_set_custom_string(): Set animation string to s2l50bl7A1-B1-C4-B3-A2
[    236][D] har_collide_with_har(): HAR ELECTRA to HAR KATANA collision at 116,165!
[    236][D] har_collide_with_har(): HAR KATANA animation set to s2l50bl7A1-B1-C4-B3-A2
[    236][D] har_collide_with_har(): HAR KATANA going to next move 36
[    237][D] har_collide_with_har(): COLLISIONS: Disabled for this frame.
[    237][E] audio_play_sound(): Unable to play sound: No free channels available
[    238][D] har_collide_with_har(): COLLISIONS: Disabled for this frame.

Thread 10 "SDLAudioP2" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffb7fff6c0 (LWP 3632)]
0x00007ffff7b585c9 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff7b585c9 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7f23412 in xmp_play_buffer () from /lib/x86_64-linux-gnu/libxmp.so.4
#2  0x000055555555ea38 in audio_xmp_render (userdata=0x0, stream=0x5555570731a0 "", len=8192)
    at /mnt/c/github/openomf/src/audio/audio.c:168
#3  0x00007ffff7dd54c0 in ?? () from /lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0
#4  0x00007ffff7c1cfb8 in ?? () from /lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#5  0x00007ffff7c89085 in ?? () from /lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#6  0x00007ffff7d2ab79 in ?? () from /lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#7  0x00007ffff7a8f044 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00007ffff7b0f61c in ?? () from /lib/x86_64-linux-gnu/libc.so.6

not sure if the [ 237][E] audio_play_sound(): Unable to play sound: No free channels available has something todo with it

I thought i'd mention this here just in case others come across it

katajakasa commented 7 months ago

Hi!

Which version of SDL2_mixer and SDL2 are you running ?

joyrider3774 commented 7 months ago

Hi,

on my debian x86_64 wsl2 instance it are these libs (from the repo's): image

image

image

on the arm rg35xx plus it was

image

however be aware this is a patched SDL2 library that adds support for mali driver

edit: i also noticed in the build i did for arm RG35xx plus without SDL2 mixer changes (https://github.com/omf2097/openomf/commit/4287067184d9f16d02035f6cf0abcafb0f9755be) after a while in the demo mode only music is playing no more sound effects but not sure it's relevant to this crash as i noticed in the SDL_Mixer build it also said no free audio channels available just before the crash

katajakasa commented 7 months ago

Those library dumps don't really mean much since they only have the major version. Please try "apt-cache policy libsdl2-mixer-2.0 libsdl2-2.0".

joyrider3774 commented 7 months ago

hi sorry here is the output of it for the debian one on the arm one i can't do it as they do not come from apt

image

katajakasa commented 7 months ago

Ok, thanks. Those seem to be fine. I might have a fix, it seems to be a combination of too low a channel count for the mixer and a buffer index issue.

joyrider3774 commented 7 months ago

ok i can easily test it out on my pc, I just had it crashed on another location and it indeed mentioned again no available free channels so i think you are on the right track

image

katajakasa commented 7 months ago

Can you try compiling from this branch/PR: https://github.com/omf2097/openomf/pull/500 ?

katajakasa commented 7 months ago

The "No free channels" might still show up, as that is just preventing the audio system from hogging too much processor time. No point in playing a kiloton of sounds at the same time, since they will just start souding like mush at that point anyways :)

joyrider3774 commented 7 months ago

ok i'm testing it (my build did not have your last commit about memory clearing but did have the 3 inital commits in that branch. The game has been running the demo mode already for about 15 minutes. It also loaded the arena with figther jets bombing the ground and the game did not crash so it seems to have fixed it. I'll quit the demo and pull the last commit as well and retest but so far it seems all good and no crashes yet on the x86_64 version

katajakasa commented 7 months ago

Went ahead and merged the changes. I'll just roll a new branch if (when) more problems show up ;)

joyrider3774 commented 7 months ago

np, demo mode is still running fine.

I also checked what happened when the sound of the jetfighters bombing the ground played and it showed this but no crash so should indeed be fixed i think. I still need to test it on the handheld but i'm guessing it will be fine as before the game crashed within 1-2 minutes when running the demo mode

image

so think its safe to close this

katajakasa commented 7 months ago

Alrighty then. Please open up a new ticket if stuff shows up :)

Thanks for testing!

Closed as fixed.