[Scummvm-git-logs] scummvm master -> 173deed054190bb2ba649c3e0721fc14ddebd2d0

bluegr noreply at scummvm.org
Wed Oct 21 06:40:43 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
173deed054 SKY: Fix race conditions


Commit: 173deed054190bb2ba649c3e0721fc14ddebd2d0
    https://github.com/scummvm/scummvm/commit/173deed054190bb2ba649c3e0721fc14ddebd2d0
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2026-10-21T09:40:38+03:00

Commit Message:
SKY: Fix race conditions

The music timer callback runs pollMusic() under _mutex. When a new track
starts, pollMusic() calls stopMusicInternal(), which deletes all
channels. Meanwhile setVolume() on the main thread loops over _channels
without the lock. If both happen at once, it calls updateVolume() on a
deleted channel object.

musicIsPlaying(), which the intro polls in a loop, has the same problem
with isActive().

Changed paths:
    engines/sky/music/adlibmusic.cpp
    engines/sky/music/gmmusic.cpp
    engines/sky/music/mt32music.cpp
    engines/sky/music/musicbase.cpp


diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp
index c12e826e7be..9b784c48c35 100644
--- a/engines/sky/music/adlibmusic.cpp
+++ b/engines/sky/music/adlibmusic.cpp
@@ -90,6 +90,7 @@ void AdLibMusic::startDriver() {
 }
 
 void AdLibMusic::setVolume(uint16 param) {
+	Common::StackLock lock(_mutex);
 	_musicVolume = param;
 	for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++)
 		_channels[cnt]->updateVolume(_musicVolume);
diff --git a/engines/sky/music/gmmusic.cpp b/engines/sky/music/gmmusic.cpp
index 124de84d54c..84e287648b3 100644
--- a/engines/sky/music/gmmusic.cpp
+++ b/engines/sky/music/gmmusic.cpp
@@ -58,6 +58,7 @@ GmMusic::~GmMusic() {
 }
 
 void GmMusic::setVolume(uint16 param) {
+	Common::StackLock lock(_mutex);
 	_musicVolume = param;
 	for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++)
 		_channels[cnt]->updateVolume(_musicVolume);
diff --git a/engines/sky/music/mt32music.cpp b/engines/sky/music/mt32music.cpp
index 62c4e69998d..11fc656f64c 100644
--- a/engines/sky/music/mt32music.cpp
+++ b/engines/sky/music/mt32music.cpp
@@ -61,6 +61,7 @@ void MT32Music::timerCall() {
 }
 
 void MT32Music::setVolume(uint16 volume) {
+	Common::StackLock lock(_mutex);
 	uint8 sysEx[10] = "\x41\x10\x16\x12\x10\x00\x16\x00\x00";
 	_musicVolume = volume;
 	sysEx[7] = (volume > 100) ? 100 : (uint8)volume;
diff --git a/engines/sky/music/musicbase.cpp b/engines/sky/music/musicbase.cpp
index 64cf0cd6e86..9ab9978351f 100644
--- a/engines/sky/music/musicbase.cpp
+++ b/engines/sky/music/musicbase.cpp
@@ -63,6 +63,9 @@ void MusicBase::loadSection(uint8 pSection) {
 bool MusicBase::musicIsPlaying() {
 	if (_mixer->isSoundHandleActive(_musicHandle))
 		return true;
+	// not before the mixer call: the mixer thread holds its lock while
+	// calling pollMusic()
+	Common::StackLock lock(_mutex);
 	for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++)
 		if (_channels[cnt]->isActive())
 			return true;




More information about the Scummvm-git-logs mailing list