From 1b07a9d34cfaf6bd9f916f3fff5a4247e1c259c6 Mon Sep 17 00:00:00 2001 From: "Stephen C. Wills" Date: Sat, 14 Feb 2026 06:20:47 -0500 Subject: [PATCH] Release lock before finalizing sound samples (#8468) --- Source/engine/sound.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/engine/sound.cpp b/Source/engine/sound.cpp index 49fb0ba7c..ac13b862b 100644 --- a/Source/engine/sound.cpp +++ b/Source/engine/sound.cpp @@ -193,8 +193,15 @@ const auto OptionChangeDevice = (GetOptions().Audio.device.SetValueChangedCallba void ClearDuplicateSounds() { - const std::lock_guard lock(*duplicateSoundsMutex); - duplicateSounds.clear(); + // Move sound samples to a temporary list, + // avoiding a deadlock that involves SDL's + // mixer lock being taken by finalizers + std::list> drain; + { + const std::lock_guard lock(*duplicateSoundsMutex); + drain = std::move(duplicateSounds); + duplicateSounds.clear(); + } } void snd_play_snd(TSnd *pSnd, int lVolume, int lPan, int userVolume)