Crash during RLE + Alpha blitting

I’ve posted this before, but seems nobody paid any attention.
Now I’ve got this bug again, which forced me to drop all
RLEACCEL from my code for things to go normal. I use SDL 1.2.3
on Linux with software surface only.

Since I don’t have much knowledge of how RLE is implemented
in SDL and even RLE itself, I am not in the position to fix the
problem and submit a patch. I hope somebody can look into the
function

int SDL_RLEAlphaBlit(..) 

in file src/video/SDL_RLEaccel.c

A brief decription of how this bug happens:

when I switch between rooms in my game, I need to blit the
room’s forground (alpha enabled) onto background, before I
can display sprites, etc. Normally it just runs fine, but
when I click faster to make rooms switches at a higher speed
back and forth, it crashes during the background-to-forground
blitting call, right inside function SDL_RLEAlphaBlit(…)
at line 865.

After I removed all RLE flag from my code, things go back to
normal again.

Regards,
.paul.

I’ve posted this before, but seems nobody paid any attention.
Now I’ve got this bug again, which forced me to drop all
RLEACCEL from my code for things to go normal. I use SDL 1.2.3
on Linux with software surface only.

Did you try the latest CVS snapshot? I remember an alpha RLE bug
was fixed there a while back. Also, it helps for you to generate
a complete minimal example that we can compile and debug.

The latest CVS code is at:
http://www.libsdl.org/cvs.html

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

It seems that current snapshot doesn’t solve the problem either.
I’m having a hard time to reproduce the bug under a minimal
example because it is a strange behavior that works alright
under normal speed but crashs under faster speed, and not
everytime.

I’ll keep working on it, and try to post the example. Thanks
for the excellent lib though!

Regards,
.paul.On Tue, Apr 02, 2002 at 09:43:59PM -0800, Sam Lantinga wrote:

Did you try the latest CVS snapshot? I remember an alpha RLE bug
was fixed there a while back. Also, it helps for you to generate
a complete minimal example that we can compile and debug.

First of all, as Sam suggested, try the latest CVS. If that still
crashes…

I’ve posted this before, but seems nobody paid any attention.

Maybe no one managed to repeat it…?

Now I’ve got this bug again, which forced me to drop all
RLEACCEL from my code for things to go normal. I use SDL 1.2.3
on Linux with software surface only.

I’ve been using alpha + RLE rather extensively and never had a problem.

As usual a minimal example would help, if you can figure out how to write
one that causes the same problem. If that fails (can be hard to figure
out what’s actually triggering it), making the full code + data
available, if possible, might be better than plain guessing.

Since I don’t have much knowledge of how RLE is implemented
in SDL and even RLE itself, I am not in the position to fix the
problem and submit a patch. I hope somebody can look into the
function

int SDL_RLEAlphaBlit(…)

in file src/video/SDL_RLEaccel.c

A brief decription of how this bug happens:

when I switch between rooms in my game, I need to blit the
room’s forground (alpha enabled) onto background, before I
can display sprites, etc. Normally it just runs fine, but
when I click faster to make rooms switches at a higher speed
back and forth, it crashes during the background-to-forground
blitting call, right inside function SDL_RLEAlphaBlit(…)
at line 865.

Are you by any chance using threads?
(Other than the main one, that is. :wink:

If the blitting normally works for all of the surfaces involved, this
sounds more like a thread/sync/locking problem to me… (“Stressing” the
application would occasionally result in SDL calls being used from
multiple threads, locking to be “forgotten”, or something like that.)

After I removed all RLE flag from my code, things go back to
normal again.

If it’s anything like the above, it might be because non-RLE surfaces are
much simpler and thus less sensitive. (I’d assume that corrupt RLE data
could cause Bad Things to happen.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 03 April 2002 06:30, paul at theV.net wrote:

I’d suggest building it with debug info, so you can trace down exactly where
in SDL it is crashing. Might shed some light on things.

-Jason> ----- Original Message -----

From: paul@thev.net ()
To:
Sent: Wednesday, April 03, 2002 12:37 PM
Subject: Re: [SDL] crash during RLE + Alpha blitting

On Tue, Apr 02, 2002 at 09:43:59PM -0800, Sam Lantinga wrote:

Did you try the latest CVS snapshot? I remember an alpha RLE bug
was fixed there a while back. Also, it helps for you to generate
a complete minimal example that we can compile and debug.

It seems that current snapshot doesn’t solve the problem either.
I’m having a hard time to reproduce the bug under a minimal
example because it is a strange behavior that works alright
under normal speed but crashs under faster speed, and not
everytime.

I’ll keep working on it, and try to post the example. Thanks
for the excellent lib though!

Regards,
.paul.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Are you by any chance using threads?
(Other than the main one, that is. :wink:

If the blitting normally works for all of the surfaces involved, this
sounds more like a thread/sync/locking problem to me… (“Stressing” the
application would occasionally result in SDL calls being used from
multiple threads, locking to be “forgotten”, or something like that.)

The only other threads I use are those playing wave/music
managed by SDL_Mixer.

After I removed all RLE flag from my code, things go back to
normal again.

If it’s anything like the above, it might be because non-RLE surfaces are
much simpler and thus less sensitive. (I’d assume that corrupt RLE data
could cause Bad Things to happen.)

I was initially suspecting some mem problem or recursive
lua->C->lua->C… situations in other parts of my game, but it
always crashed right in RLE blitting if it does crash at all.
It makes me wonder why.

Anyway, thank you all for helping! I’ll give it a few other tries!

Regards,
.paul.On Wed, Apr 03, 2002 at 07:41:25PM +0200, David Olofson wrote:

Another idea: Pointer errors, or indexing outside an array? Sounds like
you’re corrupting data that SDL uses… Any other problems with the code,
or is this the only “weird thing” or bug you know about?

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 03 April 2002 19:37, paul at theV.net wrote:

On Tue, Apr 02, 2002 at 09:43:59PM -0800, Sam Lantinga wrote:

Did you try the latest CVS snapshot? I remember an alpha RLE bug
was fixed there a while back. Also, it helps for you to generate
a complete minimal example that we can compile and debug.

It seems that current snapshot doesn’t solve the problem either.
I’m having a hard time to reproduce the bug under a minimal
example because it is a strange behavior that works alright
under normal speed but crashs under faster speed, and not
everytime.