[SDL] Crash in SDL_mixer post-mixing callback on x86 Mac running XP

Ryan C. Gordon icculus at icculus.org
Sun Apr 8 21:57:06 PDT 2007


James Haley wrote:
> The sound code of my Doom port, the Eternity Engine, is crashing
> for one of my users who is running XP on an x86 Mac machine. When
> compiled using SDL 1.2.10 and SDL_mixer 1.2.7, the program suffers
> a crash at a seemingly arbitrary point within the post-mix callback
> function. The game actually remains playable, but the standard
> Windows error report dialog appears over the screen and the sound
> begins to constantly repeat the last bytes of sound played. When
> compiled with SDL 1.2.11, the main game thread also locks up.
> 
> The application error reported is 0xc0000005 (a memory access error
> according to MSDN).
> 
> Here is a screenshot of the error happening:
> http://sl4.dmclub.org/ee_error.png
> 
> And in this folder are some shots of the error report:
> http://sl4.dmclub.org/wads/ee-error/
> 
> The error seems to occur within the function I_SDLUpdateSound
> (this is the closest symbol to the crash address found in the map file
> generated by Visual C++). That function can be found in this file:
> 
> http://eternity.mancubus.net/svn/trunk/eternity/source/i_sound.c
> 
> I cannot make any inroads against this problem, since the crash is
> only occurring for this particular user. Literally thousands of man hours
> of play testing have gone into the game without this error ever
> occuring elsewhere, so I'm hesitant to blame my own code. If
> anyone has any clues as to what could cause this, I'd be highly
> appreciative.

I'm wondering if he's got an onboard audio chip that can only ever do 
48000Hz for a sample rate...SDL would probably be trying to upsample, 
incorrectly, from 44100Hz.

SDL 1.2 is buggy when resampling from rates that aren't multiples...so 
it could do 24000Hz to 48000Hz or 48000Hz to 96000Hz, but 44100 to 48000 
would probably cause an internal buffer in SDL to overflow.

Add a call to Mix_QuerySpec() in there after the Mix_OpenAudio() call 
and see what it reports. Consider failing to initialize the game's audio 
subsystem if Mix_QuerySpec() doesn't report a frequency that 
snd_samplerate is a multiple of (or vice versa)...at least, until 
someone fixes that bug in SDL. Hell, SDL should probably just fail in 
this case, in the meantime, too.

Based on a first look at your code, that would be my best guess. Most 
audio hardware can do 41000Hz, but I've seen motherboard chips that can 
only do 48000, and you might have just stumbled upon one for the first time.

--ryan.




More information about the SDL mailing list