SDL_Mixer crash on loading sounds

My game has about 80 sound effects it loads on startup. It works just fine on the Mac using SDL_Mixer, but crashes during loading of sounds on Windows.

The odd thing is, if I enable the debugger, it works just fine. This makes it very difficult to debug, since I can’t reproduce the problem until I’m not using the debugger.

The sound files loaded are .wav files. Some of them load fine, but others seem to cause a crash. A while ago I tried isolating which sound effects were causing the crashes and tried to avoid loading them, but it seems somewhat sporadic – removing some causes others that weren’t causing crashes to then cause a crash. When it crashes, the main error dialog shows, among other things:

Modname: ntdll.dll

Just not sure where to proceed from here. Any ideas what to look at? Again, given that the debug version runs just fine, I’m not sure how to go about debugging this. (And also, since attempting to remove the “bad .wav” files causes other ones to crash instead.)

Using OpenAL instead works just fine, but I get no audio on some systems, while music does work (music is done with SDL_Mixer), so I’d like to get SDL_Mixer working for SFX too if possible.

I’ve had nothing but trouble with SDL_mixer on Windows. My sounds loaded
fine, but there was clicking and popping at random intervals, and it was
generally unreliable. </bitter rant>

You might try to get a sound conversion command line tool, and run all your
wavs through it so as to standardize them. If you’ve collected different
wav files from different sources, maybe SDL_mixer is getting tripped over
one of kind of file format? *IFF/WAVE files are allowed to be arranged in
many different ways, even having the header at the end. It’s not always
practical for software to support every arrangement. I don’t have an answer
for the debug/release discrepancy, but try standardizing your audio.

Good luck.On Sun, Dec 18, 2011 at 10:08 AM, VernJensen wrote:

**
My game has about 80 sound effects it loads on startup. It works just fine
on the Mac using SDL_Mixer, but crashes during loading of sounds on
Windows.

The odd thing is, if I enable the debugger, it works just fine. This makes
it very difficult to debug, since I can’t reproduce the problem until I’m
not using the debugger.

The sound files loaded are .wav files. Some of them load fine, but others
seem to cause a crash. A while ago I tried isolating which sound effects
were causing the crashes and tried to avoid loading them, but it seems
somewhat sporadic – removing some causes others that weren’t causing
crashes to then cause a crash. When it crashes, the main error dialog
shows, among other things:

Modname: ntdll.dll

Just not sure where to proceed from here. Any ideas what to look at?
Again, given that the debug version runs just fine, I’m not sure how to go
about debugging this. (And also, since attempting to remove the "bad .wav"
files causes other ones to crash instead.)

Using OpenAL instead works just fine, but I get no audio on some systems,
while music does work (music is done with SDL_Mixer), so I’d like to get
SDL_Mixer working for SFX too if possible.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I will do that. Got any tools you recommend?

I’ve done further debugging, and have managed to get the program to run successfully by removing some 15 or so sounds. Other sounds cause an instant crash upon playback, so removing another 7 or so has eliminated most of that.

The tricky part is that the crash usually happens on the following sound. That is, if I load a bad sound, that won’t cause a crash – rather it’ll cause the next sound loaded to crash. Same with playback. Playing back a bad sound won’t (usually) crash right then, but the next sound played back will crash.

I just tried using the free “Audacity” to re-save some of the .wav files. One of them it successfully allowed to load without crashing. The other two, it had no effect – they still cause it to crash upon loading.

Any stacktraces you can share?On Sun, Dec 18, 2011 at 11:14 AM, VernJensen wrote:

**
I just tried using the free “Audacity” to re-save some of the .wav files.
One of them it successfully allowed to load without crashing. The other
two, it had no effect – they still cause it to crash upon loading.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Check the way you manage the waves lifecycle in your game, i.e. freeing a sound and trying to play it later.

Cheers,

Andre> ----- Original Message -----

From: VernJensen [mailto:vern@actionsoft.com]
Sent: Saturday, December 17, 2011 10:14 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL_Mixer crash on loading sounds

I just tried using the free “Audacity” to re-save some of the .wav files. One of them it successfully allowed to load without crashing. The other two, it had no effect – they still cause it to crash upon loading.

andre –

I don’t free any sounds during the game. And, the game runs fine on the Mac. I’m 99% certain it’s not programmer error (at least on my part). It’s something with SDL_Mixer not handling certain kinds of WAVs properly.

eclectocrat - I am on Windows XP, and can’t seem to copy and paste the stack trace. And when I open up the file at the path where it says information stored, the stack trace is not there – only a listing of what dlls were loaded. I’d be happy to share a stack trace if it’s possible, you’d just have to tell me how.

For an example of what I mean, I get this as one of the files. Not very useful:

<?xml version="1.0" encoding="UTF-16"?>

I said that because this kind of behavior where the app will crash on release but not on debug builds (or crashes on one platform and not on another one) is a clue to bugs in the code. Read this for some examples of why this is so:

http://altdevblogaday.com/2011/07/12/the-unexpected-behaviour-of-debug-builds/

Cheers,

Andre> ----- Original Message -----

From: VernJensen [mailto:vern@actionsoft.com]
Sent: Saturday, December 17, 2011 10:34 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL_Mixer crash on loading sounds

andre –

I don’t free any sounds during the game. And, the game runs fine on the Mac. I’m 99% certain it’s not programmer error (at least on my part). It’s something with SDL_Mixer not handling certain kinds of WAVs properly.

eclectocrat - I am on Windows XP, and can’t seem to copy and paste the stack trace. And when I open up the file at the path where it says information stored, the stack trace is not there – only a listing of what dlls were loaded. I’d be happy to share a stack trace if it’s possible, you’d just have to tell me how.

This sounds really familiar. In a game of mine, I just started getting a
crash in release mode with a useless ntdll backtrace in debug mode (bt
points at the dll and two ??? frames). I threw out the function I was
working on, rewrote it, and had no more such problems. Perhaps some of
your code is doing something naughty?

Jonny DOn Sat, Dec 17, 2011 at 11:33 PM, wrote:

I said that because this kind of behavior where the app will crash on
release but not on debug builds (or crashes on one platform and not on
another one) is a clue to bugs in the code. Read this for some examples of
why this is so:

http://altdevblogaday.com/2011/07/12/the-unexpected-behaviour-of-debug-builds/

Cheers,

Andre

-----Original Message-----
From: VernJensen [mailto:vern at actionsoft.com]
Sent: Saturday, December 17, 2011 10:34 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL_Mixer crash on loading sounds

andre –

I don’t free any sounds during the game. And, the game runs fine on the
Mac. I’m 99% certain it’s not programmer error (at least on my part). It’s
something with SDL_Mixer not handling certain kinds of WAVs properly.

eclectocrat - I am on Windows XP, and can’t seem to copy and paste the
stack trace. And when I open up the file at the path where it says
information stored, the stack trace is not there – only a listing of what
dlls were loaded. I’d be happy to share a stack trace if it’s possible,
you’d just have to tell me how.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Try valgrind and see if it captures any corruption in the SDL_mixer code.

  • chrisOn 11-12-17 09:08 PM, VernJensen wrote:

Just not sure where to proceed from here. Any ideas what to look at? Again,
given that the debug version runs just fine, I’m not sure how to go about
debugging this. (And also, since attempting to remove the “bad .wav” files
causes other ones to crash instead.)

Make sure to get a crash error fron sdl or window and output it to a file.
You can output to file at intervals in your code to see where the code
crashes also. Could be as simple as one of the files is missing or not
named correctly and the debud can recover while the program can not.On Sat, Dec 17, 2011 at 8:08 PM, VernJensen wrote:

**
My game has about 80 sound effects it loads on startup. It works just fine
on the Mac using SDL_Mixer, but crashes during loading of sounds on
Windows.

The odd thing is, if I enable the debugger, it works just fine. This makes
it very difficult to debug, since I can’t reproduce the problem until I’m
not using the debugger.

The sound files loaded are .wav files. Some of them load fine, but others
seem to cause a crash. A while ago I tried isolating which sound effects
were causing the crashes and tried to avoid loading them, but it seems
somewhat sporadic – removing some causes others that weren’t causing
crashes to then cause a crash. When it crashes, the main error dialog
shows, among other things:

Modname: ntdll.dll

Just not sure where to proceed from here. Any ideas what to look at?
Again, given that the debug version runs just fine, I’m not sure how to go
about debugging this. (And also, since attempting to remove the "bad .wav"
files causes other ones to crash instead.)

Using OpenAL instead works just fine, but I get no audio on some systems,
while music does work (music is done with SDL_Mixer), so I’d like to get
SDL_Mixer working for SFX too if possible.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Vern, I had the exact same symptoms a long time ago. My 48khz sounds
were failing, but 44khz sounds were working. That particular problem
should be fixed now; I just mention it in case you’re using an old
enough version of SDL. http://bugzilla.libsdl.org/show_bug.cgi?id=911

Jeremy, I had a problem a couple weeks ago with sounds clicking and
popping on Windows, but not on Linux. I was using SDL_RWFromMem to
create my RWops from .wav files. It turns out that when I was opening
my .wav files I forgot to open them as ios::binary. This only caused
problems on Windows; very annoying.–
Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com

Message: 2
Date: Sun, 18 Dec 2011 10:30:58 +0800
From: Jeremy Jurksztowicz
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL_Mixer crash on loading sounds
Message-ID:
? ? ? ?<CACjfSQwr7tkXMDze4sw=KJHza5QRLUxvxeO-kXxmOGm=9nSO4w at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

I’ve had nothing but trouble with SDL_mixer on Windows. My sounds loaded
fine, but there was clicking and popping at random intervals, and it was
generally unreliable. </bitter rant>

You might try to get a sound conversion command line tool, and run all your
wavs through it so as to standardize them. If you’ve collected different
wav files from different sources, maybe SDL_mixer is getting tripped over
one of kind of file format? *IFF/WAVE files are allowed to be arranged in
many different ways, even having the header at the end. It’s not always
practical for software to support every arrangement. I don’t have an answer
for the debug/release discrepancy, but try standardizing your audio.

Good luck.

On Sun, Dec 18, 2011 at 10:08 AM, VernJensen wrote:

**
My game has about 80 sound effects it loads on startup. It works just fine
on the Mac using SDL_Mixer, but crashes during loading of sounds on
Windows.

The odd thing is, if I enable the debugger, it works just fine. This makes
it very difficult to debug, since I can’t reproduce the problem until I’m
not using the debugger.

The sound files loaded are .wav files. Some of them load fine, but others
seem to cause a crash. A while ago I tried isolating which sound effects
were causing the crashes and tried to avoid loading them, but it seems
somewhat sporadic – removing some causes others that weren’t causing
crashes to then cause a crash. When it crashes, the main error dialog
shows, among other things:

Modname: ntdll.dll

Just not sure where to proceed from here. Any ideas what to look at?
Again, given that the debug version runs just fine, I’m not sure how to go
about debugging this. (And also, since attempting to remove the "bad .wav"
files causes other ones to crash instead.)

Using OpenAL instead works just fine, but I get no audio on some systems,
while music does work (music is done with SDL_Mixer), so I’d like to get
SDL_Mixer working for SFX too if possible.

Chris – valgrind is for Linux, not Windows.

I “solved” my problem by switching sound engines to irrKlang. It costs money, but works.

I looked that up and I’ve got to say wow. I mean whatever you can
understand better to get started with is great but after you get your teeth
sharper take another look at sdl mixer because it’s astonishingly simple
and robust. Whatever issue you had was probably a simple chronological or
syntax error.On Tue, Dec 27, 2011 at 11:45 PM, VernJensen wrote:

**
Chris – valgrind is for Linux, not Windows.

I “solved” my problem by switching sound engines to irrKlang. It costs
money, but works.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’ve sent Sam my project and he’ll be taking a look at it this weekend. It’s likely a buffer overrun in SDL_Mixer or something like that.

I agree that the API to SDL_Mixer is very robust and simple, but the code itself – when it comes to fixing bugs – is a little beyond me.

Sam is a great coder. I can harldy believe you convinced him to
troubleshoot your code. That’s awesome. I’m sure he’ll find your mistake. I
have a buddy that troubleshoots projects professionally and still, I’ve
never been more impressed with the versitility and depth of understanding
of any other coder. If Sam can’t figure it out then I for one would give up
on it.On Thu, Jan 5, 2012 at 2:06 PM, VernJensen wrote:

**
I’ve sent Sam my project and he’ll be taking a look at it this weekend.
It’s likely a buffer overrun in SDL_Mixer or something like that.

I agree that the API to SDL_Mixer is very robust and simple, but the code
itself – when it comes to fixing bugs – is a little beyond me.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It sounds like you’re still assuming it’s a bug in my code, not in SDL_Mixer.