Page 1 of 1

[1.1.104][mac-arm] Crash changing audio settings SoundMixerSDL.cpp (31): getFinalVolume

Posted: Mon Feb 19, 2024 9:38 pm
by rvb30
Game Version: 1.1.104 (build 62119, mac-amd64)
Save was a heavily modded Space Exploration run, probably not relevant but I can provide it if you want it.

1. What did you do?
Switched from "default device" to my laptop speakers in audio settings, then switched back again. I couldn't hear any game sounds and was attempting to debug/fix that by switching the devices to and fro. (I've had success with this technique in other games when I [dis]connected bluetooth headphones so it was a logical thing to try.

2. What happened?
Game crash, logs seem to suggest a segfault.
```
23209.396 [Audio] Backend:SDL(default); Driver:coreaudio, Device:MacBook Pro Speakers, Depth:16, Channels:2, Frequency:44100
23214.026 [Audio] Backend:SDL(default); Driver:coreaudio, Device:Default device, Depth:16, Channels:2, Frequency:44100
23215.720 Error CrashHandler.cpp:639: Received SIGSEGV
Factorio crashed. Generating symbolized stacktrace, please wait ...
```

3. What did you expect to happen instead? It might be obvious to you, but do it anyway!
The game not crash, and potentially fix my audio issues

4. Does it happen always, once, or sometimes?
One off

5. If you can reproduce the issue provide the exact steps!
Can't reproduce unfortunately, will update the report if it happen again.

Re: [Donion] [1.1.104][mac-arm] Crash changing audio settings SoundMixerSDL.cpp (31): getFinalVolume

Posted: Tue Feb 20, 2024 9:19 pm
by heartosis
I had a similar crash on Windows 10, also on 1.1.104, while starting a run with the Ultracube mod and a few others. I was listening to music in Chrome and eventually noticed sound wasn't working in Factorio because I couldn't hear an alarm I'd set up. When I went to switch devices in the settings (from default device to my speaker device), it crashed almost immediately. I don't see how to upload logs on a reply, but I can upload my logs in a new post if that would be helpful. FWIW, the line numbers were slightly different in my stacktrace:

Code: Select all

c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\sound\sdl\soundmixersdl.cpp (29): SoundMixerSDL::getFinalVolume
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\sound\sdl\soundinstancesdl.cpp (114): SoundInstanceSDL::setVolume
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\sound\entityworkingsound.cpp (44): EntityWorkingSound::EntityWorkingSound
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\sound\environmentsoundplayer.cpp (245): EnvironmentSoundPlayer::update
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\game.cpp (446): Game::prepareRender
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\mainloop.cpp (1156): MainLoop::prepare
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\mainloop.cpp (716): MainLoop::mainLoopStep
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\mainloop.cpp (423): MainLoop::run
c:\users\build\appdata\local\temp\factorio-build-axh5wp\src\main.cpp (1267): wmain
Logs right before crash:

Code: Select all

2899.146 [Audio] Backend:SDL(default); Driver:wasapi, Device:Realtek Digital Output (Realtek(R) Audio), Depth:16, Channels:2, Frequency:44100
2926.316 [Audio] Backend:SDL(default); Driver:wasapi, Device:Speakers (AudioQuest DragonFly Black v1.5), Depth:16, Channels:2, Frequency:44100
2929.605 Error CrashHandler.cpp:639: Received SIGSEGV

Re: [Donion] [1.1.104][mac-arm] Crash changing audio settings SoundMixerSDL.cpp (31): getFinalVolume

Posted: Wed Feb 21, 2024 4:15 pm
by Donion
Thanks for the reports.
This turned out to be a pretty rare crash. I wasn't able to reproduce it organically but looking at the stack traces I was able to force the situation in a test environment.
It should be fixed in the next release.

Re: [1.1.104][mac-arm] Crash changing audio settings SoundMixerSDL.cpp (31): getFinalVolume

Posted: Thu Feb 22, 2024 9:52 am
by rvb30
That's awesome, thank you!

I'll 100% understand if the answer is no, but given that I'm a dev I'm curious if you could give any info on what was actually happening?

Re: [1.1.104][mac-arm] Crash changing audio settings SoundMixerSDL.cpp (31): getFinalVolume

Posted: Thu Feb 22, 2024 12:04 pm
by Donion
If a sound with its sound type overridden was playing at the time of audio device switch it would stop playing, making its resources available for a different sound to be played after the device switch, but it would still hold a pointer (now invalid) to a mixer. And it could happen that those resources would get allocated to a sound that would immediately try to access that mixer, it would cause the crash. So a classic use-after-free bug.