angstsmurf / spatterlight

Updated fork of Spatterlight
GNU General Public License v3.0
105 stars 5 forks source link

Crash after playing sounds #77

Open dougo opened 1 month ago

dougo commented 1 month ago

I'm playtesting a game for someone, and Spatterlight crashed after playing some sounds. Forum thread here: https://intfiction.org/t/diagnosing-a-possibly-sound-related-or-timer-related-crash-in-spatterlight-glulx/69879/6

I haven't yet been able to reproduce it, but here's the crash log in case it helps: Spatterlight-2024-07-23-002849.ips.json

erkyrath commented 1 month ago

The relevant part of this seems to be:

Thread 7 Crashed:: org.sbooth.AudioEngine.Decoder
0   SFBAudioEngine                         0x103267a08 SFB::Audio::RingBuffer::WriteAudio(AudioBufferList const*, unsigned long) + 216
1   SFBAudioEngine                         0x103272b40 SFB::Audio::Player::DecoderThreadEntry() + 2528
2   SFBAudioEngine                         0x103274cb4 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void* (SFB::Audio::Player::*)(), SFB::Audio::Player*>>(void*) + 64
3   libsystem_pthread.dylib                0x18495ef94 _pthread_start + 136
4   libsystem_pthread.dylib                0x184959d34 thread_start + 8
angstsmurf commented 1 month ago

Thanks for reporting this.

The crash seems to have occurred in a background thread created by the SFBAudioEngine library, which I am not very familiar with. Without a way to reproduce it, this is going to be difficult to debug.

EDIT: Spatterlight uses a very old version of SFBAudioEngine, so it may make sense to upgrade to the latest one. However, that will require quite a bit of work, and without a way to reproduce the crash, there is no way of telling if that fixes it.

EDIT 2: According to the backtrace it crashes somewhere in here, I suppose: https://github.com/angstsmurf/spatterlight/blob/4fd6b3dc60c9e3d6dc486ea0c1fccd1a12dca6d6/SFBAudioEngine/AudioRingBuffer.cpp#L192-L223

EDIT 3: By the way, @erkyrath, what do you use to parse the .json file? EDIT 4: Oh, right, I just had to remove the .json suffix to make Console and Xcode parse it correctly.

erkyrath commented 1 month ago

I don't know anything about the library either. The obvious blind guess is "something got deallocated while the sound-playing machinery was in the middle of using it".

angstsmurf commented 1 month ago

Yes, I've had reproducible crashes in the past when a game issued a sound or a volume change with a notification callback, and then the interpreter process was killed right before the notification happened.

This was the main reason that I switched from SDL audio to SFBAudioEngine, in the hope that the automatic reference counting would help, and I never saw any audio related crashes after that. Until now.

dougo commented 1 month ago

EDIT 3: By the way, @erkyrath, what do you use to parse the .json file? EDIT 4: Oh, right, I just had to remove the .json suffix to make Console and Xcode parse it correctly.

Sorry, forgot to mention that I had to add the .json suffix to get Github to accept the upload.

dougo commented 1 month ago

Sorry, still no luck reproducing it. 🤷‍♂️