Closed smcv closed 1 year ago
So I thought this was going to be a good test case for the SDL2 resampling bug, but it turned out to not be:
SDL_BuildAudioResamplerCVT in SDL2:
/* !!! FIXME: remove this if we can get the resampler to work in-place again. */
/* the buffer is big enough to hold the destination now, but
we need it large enough to hold a separate scratch buffer. */
cvt->len_mult *= 2;
But boswars does this in ConvertToStereo32:
return acvt.len_mult * bytes;
And counts on that return value to fit into a static buffer they use to convert audio; since they know how much space this should take, they statically allocate just enough and then don't check to see that this return value is double what they expect.
This is a bug in boswars, to be clear, but it works with real SDL 1.2 because it resamples in-place and SDL2 does not. I'm not sure how to fix this yet, and have other things to focus on right now, so I'm just leaving some notes here.
(SDL 1.2 would overflow buffers without warning if not resampling between frequencies that aren't double (11025 to 22050 would work but 44100 to 48000 would not), and maybe we need to do a simple in-place resample in this case instead of handing it to SDL2.)
Prerequisites:
pipewire-pulse
emulating PulseAudioapt install boswars
(Debian package version2.7+svn160110-5
; it's a Command & Conquer clone)libsdl1.2-compat
commit eba13ef, locally-builtlibsdl2-2.0-0
version2.24.1+dfsg-1
To reproduce:
LD_LIBRARY_PATH=.../sdl12-compat/_build boswars
SDL_VIDEODRIVER=wayland
(the backtrace below is with, but the crash also happens without)islandwar.map
)The game segfaults with:
At the time of the crash, all other threads are blocked waiting on locks, except for these two: