openal-soft icon indicating copy to clipboard operation
openal-soft copied to clipboard

1.23.0 and DSOAL crashing on exit

Open Matthaiks opened this issue 2 years ago • 5 comments

OpenAL Soft 1.23.0 and DSOAL used with some games (for instance, Planescape: Torment) are generating the Application Error (Event 1000) + DMP file in \AppData\Local\CrashDumps\ on exit. Version 1.22.0 is fine.

Windows 10 22H2 x64

Matthaiks avatar Feb 03 '23 21:02 Matthaiks

Is it only with DSOAL? Does it always happen, even by just starting/quitting the game, or does it require some play time before it crashes when quitting?

Trace logs for OpenAL Soft and DSOAL would be helpful. For OpenAL Soft, set the ALSOFT_LOGLEVEL environment variable to 3 and ALSOFT_LOGFILE to a full path+filename for it to write the log to. And for DSOAL, set DSOAL_LOGLEVEL and DSOAL_LOGFILE similarly (though use a different filename).

kcat avatar Feb 03 '23 23:02 kcat

I can verify the same on my system. I've been running through the a bunch of old artifacts in actions and so far it seems to be https://github.com/kcat/openal-soft/commit/68e04624b1f94d9bf8f9ebce5d90e64ab143efea that crashes on exit. I have logs for both. DSOAL-68e0462.log OpenAL Soft-68e0462.log DSOAL-1.23.0.log OpenAL Soft-1.23.0.log

Edit: It seems to happen regardless of the amount of time running.

Truth-Unknown avatar Feb 04 '23 00:02 Truth-Unknown

Tested 1.23.0 in GZDoom (so without DSOAL) and it seems fine. Starting/quitting is enough.

torment_alsoft_error.txt torment_dsoal_error.txt

Matthaiks avatar Feb 04 '23 00:02 Matthaiks

Might be due to how that commit makes the background COM thread dynamically managed, meaning it holds a thread handle for the background thread while a device is open. And DSOAL leaves contexts current on the threads it makes OpenAL calls on, which causes the device to stay open until those context references can be released.

So even though all DSound/OpenAL devices were closed by the app, the OpenAL device is technically still open when the app quits since some thread-local context references weren't released properly, leaving the background COM thread handle in a joinable state when global objects are destructed. std::thread calls std::terminate() if it's still joinable when the destructor runs, which happens at process exit and causes the crash.

DSOAL really shouldn't leave thread-local contexts set indefinitely, but OpenAL Soft should be more resilient to that happening (it shouldn't be allowed to crash). Though I'm not sure how to deal with thread-local contexts still being set on other threads when the device is closed by one particular thread.

kcat avatar Feb 04 '23 03:02 kcat

Instant crash if -wasapi is set in alsoft.ini. 1.22.0 lets the game run (without sound).

Matthaiks avatar Feb 04 '23 08:02 Matthaiks