SDL_mixer crash writing to 3016th byte of 8192-byte buffer

Hi,

I wrote to the list about a vague crash my Doom port, The Eternity Engine,
was suffering on an x86 Mac machine running WinXP a couple of months ago and
we couldn’t really get anywhere at that point. However, I have now been able
to rule out any fault of my own by creating a logfile that is written to
during my audio callback routine (a supposed no-no but it works fine).

At the start of the postmix callback (I_SDLUpdateSound,
http://eternity.mancubus.net/svn/trunk/eternity/source/sdl/i_sound.c), it
wrote this:

update sound start: ud=00000000, s=023A6050, len=8192; lo=023A6050,
ro=023A6052, le=023A8050

ud is the userdata pointer, s is the stream pointer, len is the length (all
of this data is passed to me by SDL_Mixer). lo is the “leftout” pointer
(left audio channel), ro is rightout, and le is leftend, or the value of
leftout at which we should stop writing any data (the value has been
appropriately calculated as s + 8192).

However, the program crashes while the update loop is still running and is
writing to the 3016th or 3017th byte of the buffer:

leftout = 023A6C18, rightout = 023A6C1A
channel 0: dl=-203, dr=-209, step=16384, stepremainder=49152, data=010B9804
channel 1: dl=-1251, dr=-1257, step=16384, stepremainder=0, data=010B4C17
channel 2: dl=-3880, dr=-3138, step=16384, stepremainder=32768,
data=010C1C54
channel 3: dl=-20372, dr=-15623, step=16384, stepremainder=0, data=010C1978
channel 4: dl=-2329, dr=-1495, step=16384, stepremainder=49152,
data=010C1584

If the I_SDLUpdateSound call had proceeded beyond the final write to the
audio buffer performed after the last log message here, there would be
another leftout/rightout message, and if it had finished the update to the
buffer, the message “end of sound update” would appear. Neither message
appears, proving the program crashed at this point.

So, the buffer that I have been handed by SDL_mixer has been invalidated by
something, or I am being lied to about the amount of available space in the
buffer. One way or another, I believe this is a bug in SDL_mixer, because
the PrBoom source port uses the same update loop as we do, but they pipe the
sound directly into SDL’s raw audio buffers. This port however does not
experience this crash.

I hope this prompts some ideas on what is going on here.

Yours,

James Haley_________________________________________________________________
Don?t miss your chance to WIN $10,000 and other great prizes from Microsoft
Office Live http://clk.atdmt.com/MRT/go/aub0540003042mrt/direct/01/

So, no ideas on this huh? I’m a bit disappointed. Let me reiterate that I’ve
ruled out any error on my own part with this sound engine. It works on 99%
of machines 100% of the time, but on this one, SDL_mixer is handing me a bad
buffer. Why? Is there nothing that can be done? We’ve already tried having
the user change the SDL audio driver and it has no effect on this crash.>From: “James Haley” <@James_Haley>

Reply-To: “A list for developers using the SDL library. (includes
SDL-announce)”
To: sdl at lists.libsdl.org
Subject: [SDL] SDL_mixer crash writing to 3016th byte of 8192-byte buffer
Date: Fri, 08 Jun 2007 00:52:33 -0500
MIME-Version: 1.0
X-Originating-IP: [72.172.45.239]
X-Originating-Email: [@James_Haley]
X-Sender: @James_Haley
Received: from diego.dreamhost.com ([66.33.216.104]) by
bay0-mc12-f16.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Thu,
7 Jun 2007 22:52:53 -0700
Received: from diego.dreamhost.com (localhost [127.0.0.1])by
diego.dreamhost.com (Postfix) with ESMTP id 482E348004;Thu, 7 Jun 2007
22:52:44 -0700 (PDT)
Received: from bay0-omc2-s34.bay0.hotmail.com
(bay0-omc2-s34.bay0.hotmail.com[65.54.246.170])by diego.dreamhost.com
(Postfix) with ESMTP id 3021148002for ; Thu, 7 Jun
2007 22:52:38 -0700 (PDT)
Received: from hotmail.com ([207.46.8.235]) by
bay0-omc2-s34.bay0.hotmail.comwith Microsoft SMTPSVC(6.0.3790.2668); Thu, 7
Jun 2007 22:52:37 -0700
Received: from mail pickup service by hotmail.com with Microsoft
SMTPSVC;Thu, 7 Jun 2007 22:52:37 -0700
Received: from 207.46.8.251 by by118fd.bay118.hotmail.msn.com with
HTTP;Fri, 08 Jun 2007 05:52:33 GMT
X-Message-Info:
6eq6CEYVokACaiuuI2Yq68bUfrMzGT6ZDY5t/UNYYYPL18ilJ+WBqZPsylOUqZcX
X-Original-To: sdl at lists.libsdl.org
X-OriginalArrivalTime: 08 Jun 2007 05:52:37.0110
(UTC)FILETIME=[37934960:01C7A991]
X-BeenThere: sdl at lists.libsdl.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: “A list for developers using the SDL library.
(includesSDL-announce)” <sdl-libsdl.org>
List-Unsubscribe:
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org,<mailto:sdl-request at lists.libsdl.org?subject=unsubscribe>
List-Archive: http://lists.libsdl.org/pipermail/sdl-libsdl.org
List-Post: <mailto:sdl at lists.libsdl.org>
List-Help: <mailto:sdl-request at lists.libsdl.org?subject=help>
List-Subscribe:
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org,<mailto:sdl-request at lists.libsdl.org?subject=subscribe>
Errors-To: sdl-bounces at lists.libsdl.org
Return-Path: sdl-bounces at lists.libsdl.org

Hi,

I wrote to the list about a vague crash my Doom port, The Eternity Engine,
was suffering on an x86 Mac machine running WinXP a couple of months ago
and we couldn’t really get anywhere at that point. However, I have now been
able to rule out any fault of my own by creating a logfile that is written
to during my audio callback routine (a supposed no-no but it works fine).

At the start of the postmix callback (I_SDLUpdateSound,
http://eternity.mancubus.net/svn/trunk/eternity/source/sdl/i_sound.c), it
wrote this:

update sound start: ud=00000000, s=023A6050, len=8192; lo=023A6050,
ro=023A6052, le=023A8050

ud is the userdata pointer, s is the stream pointer, len is the length (all
of this data is passed to me by SDL_Mixer). lo is the “leftout” pointer
(left audio channel), ro is rightout, and le is leftend, or the value of
leftout at which we should stop writing any data (the value has been
appropriately calculated as s + 8192).

However, the program crashes while the update loop is still running and is
writing to the 3016th or 3017th byte of the buffer:

leftout = 023A6C18, rightout = 023A6C1A
channel 0: dl=-203, dr=-209, step=16384, stepremainder=49152, data=010B9804
channel 1: dl=-1251, dr=-1257, step=16384, stepremainder=0, data=010B4C17
channel 2: dl=-3880, dr=-3138, step=16384, stepremainder=32768,
data=010C1C54
channel 3: dl=-20372, dr=-15623, step=16384, stepremainder=0, data=010C1978
channel 4: dl=-2329, dr=-1495, step=16384, stepremainder=49152,
data=010C1584

If the I_SDLUpdateSound call had proceeded beyond the final write to the
audio buffer performed after the last log message here, there would be
another leftout/rightout message, and if it had finished the update to the
buffer, the message “end of sound update” would appear. Neither message
appears, proving the program crashed at this point.

So, the buffer that I have been handed by SDL_mixer has been invalidated by
something, or I am being lied to about the amount of available space in the
buffer. One way or another, I believe this is a bug in SDL_mixer, because
the PrBoom source port uses the same update loop as we do, but they pipe
the sound directly into SDL’s raw audio buffers. This port however does not
experience this crash.

I hope this prompts some ideas on what is going on here.

Yours,

James Haley


Don?t miss your chance to WIN $10,000 and other great prizes from Microsoft
Office Live http://clk.atdmt.com/MRT/go/aub0540003042mrt/direct/01/


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


PC Magazine?s 2007 editors? choice for best Web mail?award-winning Windows
Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507

So, no ideas on this huh? I’m a bit disappointed. Let me reiterate that I’ve
ruled out any error on my own part with this sound engine. It works on 99%
of machines 100% of the time, but on this one, SDL_mixer is handing me a bad
buffer. Why? Is there nothing that can be done? We’ve already tried having
the user change the SDL audio driver and it has no effect on this crash.

What version of SDL_mixer are you using? Can you try the version in SVN?
Is there any chance you can reproduce it with a simpler test case?

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

This is with SDL 1.2.11 and SDL_mixer 1.2.7 (the release versions).
Unfortunately it is very difficult for us to test this problem because it is
only occuring for this one user, and he has no compiler or debugging tools
on his machine. It is also difficult to come up with a simpler test case
since the sound engine is thoroughly embedded, and I’m so unsure of what
could cause the problem in the first place.

I will, however, try to come up with something. When I do, I’ll report
anything I find here. I can also see about having him try the SVN version,
though unless binaries are readily available, this may be problematic.

Yours,

James Haley>From: Sam Lantinga

Reply-To: “A list for developers using the SDL library. (includes
SDL-announce)”
To: "A list for developers using the SDL library. (includes SDL-announce)"

Subject: Re: [SDL] SDL_mixer crash writing to 3016th byte of 8192-byte
buffer
Date: Tue, 12 Jun 2007 23:54:11 -0700

So, no ideas on this huh? I’m a bit disappointed. Let me reiterate that
I’ve
ruled out any error on my own part with this sound engine. It works on
99%
of machines 100% of the time, but on this one, SDL_mixer is handing me a
bad
buffer. Why? Is there nothing that can be done? We’ve already tried
having
the user change the SDL audio driver and it has no effect on this crash.

What version of SDL_mixer are you using? Can you try the version in SVN?
Is there any chance you can reproduce it with a simpler test case?

See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment


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


Who’s that on the Red Carpet? Play & win glamorous prizes.
http://club.live.com/red_carpet_reveal.aspx?icid=REDCARPET_hotmailtextlink3