SDL_RLEACCEL Bug

I think I’v encountered a bug in SDL (I use the last cvs version, compiled it on my own on VC++7.0).
The bug is very wierd and I really don’t know how could not been noticed by now.
I have one surface with SDL_SRCCOLORKEY | SDL_RLEACCEL set, and it blits ok on the screen, then when I
get the mouse over it I do SDL_SetAlpha(srf, SDL_SRCALPHA | RLEACCEL, 220) to the same surface to get a sort of mouseover effect…but when I try to blit this surface on the screen I got an exception in SDL.dll, in fact I’v noticed that my surface->pixels after the blit was NULL, the buffer was lost somewhere while SDL was doing conversion of the buffer for rle acceleration, and it blited the converted buffer but my surface->pixels was lost in the proccess…
If this explanation is not enought I can try to reconstruct the bug again and write down the exact location of the bug in SDL, I’v found it once with a debug build of SDL.lib after loosing about 4 hours tring to find the bug in my sources, I’v made a debug lib of SDL and found the bug was in it, but I converted all in my project now not to use RLEACCEL and it works fine…

Anyway sorry for my bad english I’m from Croatia, currently living in Moscow so…

I think I’v encountered a bug in SDL (I use the last cvs version,
compiled it on my own on VC++7.0). The bug is very wierd and I really
don’t know how could not been noticed by now. I have one surface with
SDL_SRCCOLORKEY | SDL_RLEACCEL set, and it blits ok on the screen,
then when I get the mouse over it I do SDL_SetAlpha(srf, SDL_SRCALPHA
| RLEACCEL, 220) to the same surface to get a sort of mouseover
effect…but when I try to blit this surface on the screen I got an
exception in SDL.dll, in fact I’v noticed that my surface->pixels
after the blit was NULL, the buffer was lost somewhere while SDL was
doing conversion of the buffer for rle acceleration, and it blited the
converted buffer but my surface->pixels was lost in the proccess…
If this explanation is not enought I can try to reconstruct the bug
again and write down the exact location of the bug in SDL, I’v found
it once with a debug build of SDL.lib after loosing about 4 hours
tring to find the bug in my sources, I’v made a debug lib of SDL and
found the bug was in it, but I converted all in my project now not to
use RLEACCEL and it works fine…

Hmm… if you could reproduce the bug, I’m sure that those responsible
for fixing it would find a stack-trace of the crash/exception very
helpfull… It’s pretty hard to find the bug otherwise…

Anyway sorry for my bad english I’m from Croatia, currently living
in Moscow so…

Actually, your English seems fine (what do I know, I’m not an English
teacher)… but I think people would appreciate it if you line-wrap
your posts.

-LorenOn Mon, 2002-09-30 at 03:09, Paolo Gavocanov (cTh) wrote:

If this explanation is not enought I can try to reconstruct the bug again and write down the exact location of the bug in SDL, I’v found it once with a debug build of SDL.lib after loosing about 4 hours tring to find the bug in my sources, I’v made a debug lib of SDL and found the bug was in it.

Yes, if you could point out where the bug is, that would be great.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

OK, I’ll give a try…> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Sam Lantinga
Sent: Friday, October 04, 2002 4:46 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

If this explanation is not enought I can try to reconstruct the bug
again and write down the exact location of the bug in SDL, I’v found
it once with a debug build of SDL.lib after loosing about 4 hours
tring to find the bug in my sources, I’v made a debug lib of SDL and
found the bug was in it.

Yes, if you could point out where the bug is, that would be great.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment


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

OK, I’v been trying to trace the bug for the whole day,
in facts I’v been trying to make a simple source that
reproduces the bug to send it to the list, but I really
can’t do this, I can reproduce the bug from my app but
sending the sources would be OK for me, but it is a
whole C++ implementation of SDL, somekind of lightweight
wrapper and I really think that sending it all would be
too much work for anybody to understand it and locate the
bug…

I’v come to the conclusion that the simplest way is to send
a “call stack” , a description of the surfaces involved in
the blit that causes the bug, and specs about my computer
configuration (sw and hw)…

So my config. is as follows:
PIII 650MHz, 256MB RAM, GeForce2 MX200 32Mb VRAM
WinXP, latest Detonator drivers v30.82, latest SDL from
CVS compiled with VC++7.0 as all my sources

Surfaces involved in the blit
source:
32 BitsPerPixel, 4 BytesPerPixel
r,g,b,a loss = 0
rshift = 16 (decimal)
gshift = 8 (decimal)
bshift = 0 (decimal)
ashift = 24 (decimal)
rmask = 0x00ff0000 (hex)
gmask = 0x0000ff00 (hex)
bmask = 0x000000ff (hex)
amask = 0xff000000 (hex)
colorkey = 0
alpha = 255
FLAGS : SDL_SRCALPHA | SDL_SWSURFACE
it has perPixelAlpha values set, its
created from SDL_ttf, blended text
(TTF_RenderUTF8_Blended(_ttf_font, text, foreCol))
width = 57, height = 18
pitch = 228
SDL_RLEACCEL set through call to SDL_SetAlpha

destination:
	32 BitsPerPixel, 4 BytesPerPixel
	r,g,b loss = 0, aloss = 8
	rshift = 16 (decimal)
	gshift = 8 (decimal)
	bshift = 0 (decimal)
	ashift = 0 (decimal)
	rmask = 0x00ff0000 (hex)
	gmask = 0x0000ff00 (hex)
	bmask = 0x000000ff (hex)
	amask = 0x00000000 (hex)
	colorkey = 0
	alpha = 255
	FLAGS : SDL_SRCCOLORKEY | SDL_SWSURFACE
	width = 180, height = 50
	pitch = 720
	SDL_RLEACCEL set through call to SDL_SetColorKey

the blit:
SDL_BlitSurface(source, NULL, destination, &destinationRect);
it returns 0, but after the blit source->pixels = 0x00000000!!!
the buffer is lost…

There is one thing that I’m wondering, how can I know if the surface
has the RLEACCEL flag set??? if I do :
bool m_isRLE(SDL_Surface *srf)
{
if ((srf->flags & SDL_RLEACCEL) == SDL_RLEACCEL)
return true;
else
return false;
}
it returns me always false, even if I set SDL_RLEACCEL with
SDL_SetColorKey
or SDL_SetAlpha…I’m really interested in that!!!

Anyway I’v came to the conclusion that when some SDL_BlitSurface call
gets to “sdl_rleaccel.c” line 1222 saying:

/* Now that we have it encoded, release the original pixels */
if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {

–> free( surface->pixels );
–> surface->pixels = NULL;
}

it gets lost!!! And when you do consequent blits with the surface
you get an exception (“Access violation reading location 0x???”)
at “sdl_rleaccel.c” line 870 saying:

switch(df->BytesPerPixel) {
case 2:
    if(df->Gmask == 0x07e0 || df->Rmask == 0x07e0
       || df->Bmask == 0x07e0)
	RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
    else
	RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
    break;
case 4:

–> RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
break;
}

because of reading the buffer that was lost earlier…

Here is the “call stack” of the blit function before the
buffer gets lost:
SDL_D.dll!RLEAlphaSurface
(SDL_Surface * surface=0x00eb1108) Line 1222
SDL_D.dll!SDL_RLESurface
(SDL_Surface * surface=0x00eb1108) Line 1426 + 0x9
SDL_D.dll!SDL_CalculateBlit
(SDL_Surface * surface=0x00eb1108) Line 284 + 0x9
SDL_D.dll!SDL_MapSurface
(SDL_Surface * src=0x00eb1108, SDL_Surface * dst=0x00ee3328)
Line 608 + 0x9
SDL_D.dll!SDL_LowerBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x0012f5f8,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 408 + 0xd
SDL_D.dll!SDL_UpperBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x00000000,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 521 + 0x15

!!!IMPORTANT!!!
All of this only occurs if I set the flag SDL_RLEACCEL through calls
to
SDL_SetColorKey or SDL_SetAlpha, if I don’t do this it all works
FINE!!!

By the way, I know that SDL is not officialy supported for compiling
on VC++7.0, but I’v compiled lot’s of code wich was for VC++6 on VC++7
(FreeType2, libjpeg, libzip, libpng, sdl, sdl_mixer, sdl_image,
sdl_ttf,

sdl_gfx, sdl_draw…)and it never turned to be some incompatibilies…
so I really think that VC++7.0 should not be the problem…
I don’t have VC++6.0 installed now to try it all with it, but if
someone

have some good reason to believe that VC++7.0 is the problem,
I’ll try with VC++6, LET ME KNOW about this!!!

I think that should be enought to find the bug…
Anyway, I know that this two surfaces are maybe in a bad format for
optimal
bliting, one has alpha, the other has colorKey, maybe it’s better to
convert them before the blit, but anyway SDL should not loose the
pixel buffer in any “wierd” situation and return 0, like a success
, and I think that indeed is a bug wich must be corrected…

If I can help in some other way let me know!!!

On the end I want to ask another question, has anyone noticed that
SDL apps on WinXP block the TaskBar and make it unusable
(I can’t click on any app. or TaskBar icon or shortcut,
neither the “Start” buton!!!)???

It happens allways on my machine when I’m in WinXP,
eventually after a long period it resumes to work for
some second, Win98 on the same machine does’t do that…> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Sam Lantinga
Sent: Friday, October 04, 2002 4:46 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

If this explanation is not enought I can try to reconstruct the bug
again and write down the exact location of the bug in SDL, I’v found
it once with a debug build of SDL.lib after loosing about 4 hours
tring to find the bug in my sources, I’v made a debug lib of SDL and
found the bug was in it.

Yes, if you could point out where the bug is, that would be great.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment


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

Hi,

have you tried locking the surface before using the
surf->pixels member, and then unlocking it when you are finished
reading/ writing it?

The point of an RLE surface is that the pixel data is compressed
and therefore it shouldn’t be accessible through the surf->pixels
member. This is enforced by it being set to NULL.

SDL_LockSurface(surf) is a signal to the underlying implementation
that you require access to a block of pixel data in the format
indicated by the surf->format structure. After the lock you should
find that the surf->pixels member is valid.

SDL_UnlockSurface(surf) indicates that you have finished with this
pixel data and allows it to regenerate the underlying RLE data if
you have changed it. It then sets surf->pixels to NULL so that
accidents can’t happen.

I note from the documentation that it says in the "SDL_SetColorKey"
section:

“… The surface will actually be encoded for RLE acceleration the
first time SDL_BlitSurface or SDL_DisplayFormat is called on the
surface …”

If I have guessed wrongly, please try and concoct a small demo
program as Sam requested - without this you are unlikely to get
much, useful, assistance.

Good luck with your project!

best regards,
John Popplewell.> ----- Original Message -----

From: paolo@gradpula.com (Paolo Gavocanov)
To:
Sent: Friday, October 04, 2002 5:25 PM
Subject: RE: [SDL] SDL_RLEACCEL Bug

OK, I’v been trying to trace the bug for the whole day,
in facts I’v been trying to make a simple source that
reproduces the bug to send it to the list, but I really
can’t do this, I can reproduce the bug from my app but
sending the sources would be OK for me, but it is a
whole C++ implementation of SDL, somekind of lightweight
wrapper and I really think that sending it all would be
too much work for anybody to understand it and locate the
bug…

I’v come to the conclusion that the simplest way is to send
a “call stack” , a description of the surfaces involved in
the blit that causes the bug, and specs about my computer
configuration (sw and hw)…

So my config. is as follows:
PIII 650MHz, 256MB RAM, GeForce2 MX200 32Mb VRAM
WinXP, latest Detonator drivers v30.82, latest SDL from
CVS compiled with VC++7.0 as all my sources

Surfaces involved in the blit
source:
32 BitsPerPixel, 4 BytesPerPixel
r,g,b,a loss = 0
rshift = 16 (decimal)
gshift = 8 (decimal)
bshift = 0 (decimal)
ashift = 24 (decimal)
rmask = 0x00ff0000 (hex)
gmask = 0x0000ff00 (hex)
bmask = 0x000000ff (hex)
amask = 0xff000000 (hex)
colorkey = 0
alpha = 255
FLAGS : SDL_SRCALPHA | SDL_SWSURFACE
it has perPixelAlpha values set, its
created from SDL_ttf, blended text
(TTF_RenderUTF8_Blended(_ttf_font, text, foreCol))
width = 57, height = 18
pitch = 228
SDL_RLEACCEL set through call to SDL_SetAlpha

destination:
32 BitsPerPixel, 4 BytesPerPixel
r,g,b loss = 0, aloss = 8
rshift = 16 (decimal)
gshift = 8 (decimal)
bshift = 0 (decimal)
ashift = 0 (decimal)
rmask = 0x00ff0000 (hex)
gmask = 0x0000ff00 (hex)
bmask = 0x000000ff (hex)
amask = 0x00000000 (hex)
colorkey = 0
alpha = 255
FLAGS : SDL_SRCCOLORKEY | SDL_SWSURFACE
width = 180, height = 50
pitch = 720
SDL_RLEACCEL set through call to SDL_SetColorKey

the blit:
SDL_BlitSurface(source, NULL, destination, &destinationRect);
it returns 0, but after the blit source->pixels = 0x00000000!!!
the buffer is lost…

There is one thing that I’m wondering, how can I know if the surface
has the RLEACCEL flag set??? if I do :
bool m_isRLE(SDL_Surface *srf)
{
if ((srf->flags & SDL_RLEACCEL) == SDL_RLEACCEL)
return true;
else
return false;
}
it returns me always false, even if I set SDL_RLEACCEL with
SDL_SetColorKey
or SDL_SetAlpha…I’m really interested in that!!!

Anyway I’v came to the conclusion that when some SDL_BlitSurface call
gets to “sdl_rleaccel.c” line 1222 saying:

/* Now that we have it encoded, release the original pixels */
if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {

–> free( surface->pixels );
–> surface->pixels = NULL;
}

it gets lost!!! And when you do consequent blits with the surface
you get an exception (“Access violation reading location 0x???”)
at “sdl_rleaccel.c” line 870 saying:

switch(df->BytesPerPixel) {
case 2:
if(df->Gmask == 0x07e0 || df->Rmask == 0x07e0
|| df->Bmask == 0x07e0)
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
else
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
break;
case 4:
–> RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
break;
}

because of reading the buffer that was lost earlier…

Here is the “call stack” of the blit function before the
buffer gets lost:
SDL_D.dll!RLEAlphaSurface
(SDL_Surface * surface=0x00eb1108) Line 1222
SDL_D.dll!SDL_RLESurface
(SDL_Surface * surface=0x00eb1108) Line 1426 + 0x9
SDL_D.dll!SDL_CalculateBlit
(SDL_Surface * surface=0x00eb1108) Line 284 + 0x9
SDL_D.dll!SDL_MapSurface
(SDL_Surface * src=0x00eb1108, SDL_Surface * dst=0x00ee3328)
Line 608 + 0x9
SDL_D.dll!SDL_LowerBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x0012f5f8,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 408 + 0xd
SDL_D.dll!SDL_UpperBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x00000000,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 521 + 0x15

!!!IMPORTANT!!!
All of this only occurs if I set the flag SDL_RLEACCEL through calls
to
SDL_SetColorKey or SDL_SetAlpha, if I don’t do this it all works
FINE!!!

By the way, I know that SDL is not officialy supported for compiling
on VC++7.0, but I’v compiled lot’s of code wich was for VC++6 on VC++7
(FreeType2, libjpeg, libzip, libpng, sdl, sdl_mixer, sdl_image,
sdl_ttf,

sdl_gfx, sdl_draw…)and it never turned to be some incompatibilies…
so I really think that VC++7.0 should not be the problem…
I don’t have VC++6.0 installed now to try it all with it, but if
someone

have some good reason to believe that VC++7.0 is the problem,
I’ll try with VC++6, LET ME KNOW about this!!!

I think that should be enought to find the bug…
Anyway, I know that this two surfaces are maybe in a bad format for
optimal
bliting, one has alpha, the other has colorKey, maybe it’s better to
convert them before the blit, but anyway SDL should not loose the
pixel buffer in any “wierd” situation and return 0, like a success
, and I think that indeed is a bug wich must be corrected…

If I can help in some other way let me know!!!

On the end I want to ask another question, has anyone noticed that
SDL apps on WinXP block the TaskBar and make it unusable
(I can’t click on any app. or TaskBar icon or shortcut,
neither the “Start” buton!!!)???

It happens allways on my machine when I’m in WinXP,
eventually after a long period it resumes to work for
some second, Win98 on the same machine does’t do that…

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Sam Lantinga
Sent: Friday, October 04, 2002 4:46 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

If this explanation is not enought I can try to reconstruct the bug
again and write down the exact location of the bug in SDL, I’v found
it once with a debug build of SDL.lib after loosing about 4 hours
tring to find the bug in my sources, I’v made a debug lib of SDL and
found the bug was in it.

Yes, if you could point out where the bug is, that would be great.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment


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


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

I understand that, but I’m not trying to acces the pixel buffer, I’v
only noted that it is null through the debugger,
in facts I’v checked my whole app if it was reading or writing
something
in the buffer directly, but it does not,
so that’s not the point, anyway, after the pixel buffer is null after
encoding to RLE, consequential blits with
the surface generates an access violation, so I think that maybe the
SDL_BlitSurface function doesn’t lock
or unlock it as it should do!!!> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
John Popplewell
Sent: Saturday, October 05, 2002 6:00 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

Hi,

have you tried locking the surface before using the
surf->pixels member, and then unlocking it when you are finished
reading/ writing it?

The point of an RLE surface is that the pixel data is compressed and
therefore it shouldn’t be accessible through the surf->pixels
member. This is enforced by it being set to NULL.

SDL_LockSurface(surf) is a signal to the underlying implementation
that you require access to a block of pixel data in the format
indicated by the surf->format structure. After the lock you should
find that the surf->pixels member is valid.

SDL_UnlockSurface(surf) indicates that you have finished with this
pixel
data and allows it to regenerate the underlying RLE data if you have
changed it. It then sets surf->pixels to NULL so that accidents can’t
happen.

I note from the documentation that it says in the "SDL_SetColorKey"
section:

“… The surface will actually be encoded for RLE acceleration the
first time SDL_BlitSurface or SDL_DisplayFormat is called on the
surface …”

If I have guessed wrongly, please try and concoct a small demo program
as Sam requested - without this you are unlikely to get much, useful,
assistance.

Good luck with your project!

best regards,
John Popplewell.

----- Original Message -----
From: @Paolo_Gavocanov (Paolo Gavocanov)
To:
Sent: Friday, October 04, 2002 5:25 PM
Subject: RE: [SDL] SDL_RLEACCEL Bug

OK, I’v been trying to trace the bug for the whole day,
in facts I’v been trying to make a simple source that reproduces the
bug to send it to the list, but I really can’t do this, I can
reproduce the bug from my app but sending the sources would be OK
for
me, but it is a whole C++ implementation of SDL, somekind of
lightweight wrapper and I really think that sending it all would be
too much work for anybody to understand it and locate the
bug…

I’v come to the conclusion that the simplest way is to send
a “call stack” , a description of the surfaces involved in the blit
that causes the bug, and specs about my computer configuration (sw
and

hw)…

So my config. is as follows:
PIII 650MHz, 256MB RAM, GeForce2 MX200 32Mb VRAM
WinXP, latest Detonator drivers v30.82, latest SDL from
CVS compiled with VC++7.0 as all my sources

Surfaces involved in the blit
source:
32 BitsPerPixel, 4 BytesPerPixel
r,g,b,a loss = 0
rshift = 16 (decimal)
gshift = 8 (decimal)
bshift = 0 (decimal)
ashift = 24 (decimal)
rmask = 0x00ff0000 (hex)
gmask = 0x0000ff00 (hex)
bmask = 0x000000ff (hex)
amask = 0xff000000 (hex)
colorkey = 0
alpha = 255
FLAGS : SDL_SRCALPHA | SDL_SWSURFACE
it has perPixelAlpha values set, its
created from SDL_ttf, blended text
(TTF_RenderUTF8_Blended(_ttf_font,
text, foreCol)) width = 57, height = 18
pitch = 228
SDL_RLEACCEL set through call to SDL_SetAlpha

destination:
32 BitsPerPixel, 4 BytesPerPixel
r,g,b loss = 0, aloss = 8
rshift = 16 (decimal)
gshift = 8 (decimal)
bshift = 0 (decimal)
ashift = 0 (decimal)
rmask = 0x00ff0000 (hex)
gmask = 0x0000ff00 (hex)
bmask = 0x000000ff (hex)
amask = 0x00000000 (hex)
colorkey = 0
alpha = 255
FLAGS : SDL_SRCCOLORKEY | SDL_SWSURFACE
width = 180, height = 50
pitch = 720
SDL_RLEACCEL set through call to SDL_SetColorKey

the blit:
SDL_BlitSurface(source, NULL, destination, &destinationRect); it
returns 0, but after the blit source->pixels = 0x00000000!!! the
buffer is lost…

There is one thing that I’m wondering, how can I know if the surface
has the RLEACCEL flag set??? if I do : bool m_isRLE(SDL_Surface
*srf)
{
if ((srf->flags & SDL_RLEACCEL) == SDL_RLEACCEL)
return true;
else
return false;
}
it returns me always false, even if I set SDL_RLEACCEL with
SDL_SetColorKey
or SDL_SetAlpha…I’m really interested in that!!!

Anyway I’v came to the conclusion that when some SDL_BlitSurface
call
gets to “sdl_rleaccel.c” line 1222 saying:

/* Now that we have it encoded, release the original pixels */
if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {

–> free( surface->pixels );
–> surface->pixels = NULL;
}

it gets lost!!! And when you do consequent blits with the surface
you
get an exception (“Access violation reading location 0x???”) at
"sdl_rleaccel.c" line 870 saying:

switch(df->BytesPerPixel) {
case 2:
if(df->Gmask == 0x07e0 || df->Rmask == 0x07e0
|| df->Bmask == 0x07e0)
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
else
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
break;
case 4:
–> RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
break;
}

because of reading the buffer that was lost earlier…

Here is the “call stack” of the blit function before the buffer gets
lost: SDL_D.dll!RLEAlphaSurface
(SDL_Surface * surface=0x00eb1108) Line 1222
SDL_D.dll!SDL_RLESurface
(SDL_Surface * surface=0x00eb1108) Line 1426 + 0x9
SDL_D.dll!SDL_CalculateBlit
(SDL_Surface * surface=0x00eb1108) Line 284 + 0x9
SDL_D.dll!SDL_MapSurface
(SDL_Surface * src=0x00eb1108, SDL_Surface * dst=0x00ee3328)
Line 608 + 0x9
SDL_D.dll!SDL_LowerBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x0012f5f8,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 408 + 0xd
SDL_D.dll!SDL_UpperBlit
(SDL_Surface * src=0x00eb1108, SDL_Rect * srcrect=0x00000000,
SDL_Surface * dst=0x00ee3328, SDL_Rect * dstrect=0x0012f7b0)
Line 521 + 0x15

!!!IMPORTANT!!!
All of this only occurs if I set the flag SDL_RLEACCEL through calls
to SDL_SetColorKey or SDL_SetAlpha, if I don’t do this it all works
FINE!!!

By the way, I know that SDL is not officialy supported for compiling
on VC++7.0, but I’v compiled lot’s of code wich was for VC++6 on
VC++7

(FreeType2, libjpeg, libzip, libpng, sdl, sdl_mixer, sdl_image,
sdl_ttf,

sdl_gfx, sdl_draw…)and it never turned to be some
incompatibilies…

so I really think that VC++7.0 should not be the problem… I don’t
have VC++6.0 installed now to try it all with it, but if someone

have some good reason to believe that VC++7.0 is the problem, I’ll
try

with VC++6, LET ME KNOW about this!!!

I think that should be enought to find the bug…
Anyway, I know that this two surfaces are maybe in a bad format for
optimal bliting, one has alpha, the other has colorKey, maybe it’s
better to convert them before the blit, but anyway SDL should not
loose the pixel buffer in any “wierd” situation and return 0, like a
success , and I think that indeed is a bug wich must be corrected…

If I can help in some other way let me know!!!

On the end I want to ask another question, has anyone noticed that
SDL

apps on WinXP block the TaskBar and make it unusable (I can’t click
on

any app. or TaskBar icon or shortcut, neither the "Start"
buton!!!)???

It happens allways on my machine when I’m in WinXP, eventually after
a

long period it resumes to work for some second, Win98 on the same
machine does’t do that…

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf
Of
Sam Lantinga
Sent: Friday, October 04, 2002 4:46 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

If this explanation is not enought I can try to reconstruct the
bug

again and write down the exact location of the bug in SDL, I’v
found

it once with a debug build of SDL.lib after loosing about 4 hours
tring to find the bug in my sources, I’v made a debug lib of SDL
and

found the bug was in it.

Yes, if you could point out where the bug is, that would be great.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment


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


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


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

Here is a link to an archive of ~120Kb that shows the exception… The
suplied project files are for VC++7, because I don’t have currently
VC++6 installed, but it’s 1Min. work to create a "Blank Win32
VC++application"
in VC++6 and add the one ‘main.cpp’ file to the project…so please
try
it and let me know…

http://user.rol.ru/~cth/SDLTest.rar

Hi,

I just got hold of your code. It is exactly what is required and
reproduces the problem beatifully.

In a nutshell, you are rendering one RLE encoded surface onto
another RLE encoded surface, using SDL_BlitSurface(), which calls
down through:

SDL_UpperBlit()
SDL_LowerBlit()
SDL_RLEAlphaBlit()

all of which fail to notice that a call to SDL_UnRLESurface() is
required (followed by a blit and a re-encode?) This isn’t likely
to be very efficient, so it isn’t suprising that it isn’t supported.

I don’t know what the solution is, over to the experts, but an error
message would be a lot better than this pesky crash,

cheers,
John.> ----- Original Message -----

From: paolo@gradpula.com (Paolo Gavocanov)
To:
Sent: Monday, October 07, 2002 6:23 PM
Subject: [SDL] SDL_RLEACCEL Bug

Here is a link to an archive of ~120Kb that shows the exception… The
suplied project files are for VC++7, because I don’t have currently
VC++6 installed, but it’s 1Min. work to create a "Blank Win32
VC++application"
in VC++6 and add the one ‘main.cpp’ file to the project…so please
try
it and let me know…

http://user.rol.ru/~cth/SDLTest.rar


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

Yep, that’s what I figured out myself too…but it is not the case of
RLE to RLE…
It’s an RLEAlpha blit…> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
John Popplewell
Sent: Tuesday, October 08, 2002 12:30 AM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_RLEACCEL Bug

Hi,

I just got hold of your code. It is exactly what is required and
reproduces the problem beatifully.

In a nutshell, you are rendering one RLE encoded surface onto another
RLE encoded surface, using SDL_BlitSurface(), which calls down
through:

SDL_UpperBlit()
SDL_LowerBlit()
SDL_RLEAlphaBlit()

all of which fail to notice that a call to SDL_UnRLESurface() is
required (followed by a blit and a re-encode?) This isn’t likely to be
very efficient, so it isn’t suprising that it isn’t supported.

I don’t know what the solution is, over to the experts, but an error
message would be a lot better than this pesky crash,

cheers,
John.

----- Original Message -----
From: @Paolo_Gavocanov (Paolo Gavocanov)
To:
Sent: Monday, October 07, 2002 6:23 PM
Subject: [SDL] SDL_RLEACCEL Bug

Here is a link to an archive of ~120Kb that shows the exception…
The

suplied project files are for VC++7, because I don’t have currently
VC++6 installed, but it’s 1Min. work to create a "Blank Win32
VC++application"
in VC++6 and add the one ‘main.cpp’ file to the project…so please
try it and let me know…

http://user.rol.ru/~cth/SDLTest.rar


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


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

Hi,

below is a complete, short program that reproduces this bug.

This is based on code supplied by:
Paolo (cTh) Gavocanov

Only tested on Windows, but this isn’t a Windows specific bug.

The sequence of operations is questionable, but it does reveal
a bug in the (general purpose?) SDL_BlitSurface() func.,
and in some circumstances what it does is perfectly valid.

It crashes in SDL_RLEAlphaBlit() because the destination is an
RLE surface that hasn’t had SDL_UnRLESurface() called on it.

For example, the general purpose SDL_SoftBlit() functions calls
SDL_UnRLESurface() before writing to it and then calls
SDL_RLESurface() afterwards.

This led to the enclosed patch. There may be similar problems
elsewhere in the code, but there may also be better solutions -
at one point I thought it was to do with the mapping not being
invalidated correctly but this led me nowhere.

After examining the list, I believe that this problem has actually
occured before: after asking here and getting the usual replies,
they have shrugged, worked round it, and there has never been any
example code until Paolo (cTh) Gavocanov
refused to give up!

cheers,
John.----------------------------------------------------------------------
#include <stdlib.h>
#include “SDL.h”

SDL_Surface *display = NULL;
SDL_Surface *s1 = NULL;
SDL_Surface *s2 = NULL;

int m_isRLE(SDL_Surface *srf)
{
return ((srf->flags & SDL_RLEACCEL) == SDL_RLEACCEL);
}

int loadImages()
{
int s1r, s2r;
SDL_Rect rc = { 80,20,20,10 };

s1 = SDL_CreateRGBSurface(SDL_SWSURFACE, 57, 18, 32, 
             0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
if (!s1) return 0;
SDL_FillRect( s1, NULL, SDL_MapRGB(s1->format, 221, 255, 221) );

if ( SDL_SetAlpha(s1, SDL_SRCALPHA | SDL_RLEACCEL, 255) )
    return 0;

s2 = SDL_CreateRGBSurface(SDL_SWSURFACE, 180, 50, 32, 
             0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000);
if (!s2) return 0;
SDL_FillRect( s2, NULL, SDL_MapRGB(s2->format, 0, 0, 0) );
SDL_FillRect( s2, &rc, SDL_MapRGB(s2->format, 63, 73, 83) );

SDL_SetColorKey(s2, SDL_SRCCOLORKEY | SDL_RLEACCEL, 
                SDL_MapRGB(s2->format, 0, 0, 0));

if ( SDL_BlitSurface(s1, NULL, s2, NULL) )
    return 0;

if ( SDL_BlitSurface(s2, NULL, display, NULL) )
    return 0;

s1r = m_isRLE(s1);
s2r = m_isRLE(s2);

// !!! HERE COMES THE EXCEPTION !!!
if ( SDL_BlitSurface(s1, NULL, s2, NULL) )
    return 0;
// !!! HERE COMES THE EXCEPTION !!!

SDL_UpdateRect(display, 0, 0, 0, 0);
return 1;

}

int main(int argc, char **argv)
{
SDL_Event event;

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
    fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
    exit(0);
}
atexit(SDL_Quit);

display = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
if (!display) {
    fprintf(stderr, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
    return 0;
}
SDL_FillRect(display, NULL, SDL_MapRGB(display->format, 0, 0, 0));
SDL_UpdateRect(display, 0, 0, 0, 0);

if ( !loadImages() ) exit(0);

while ( SDL_WaitEvent( &event ) ) {
    if ( event.type == SDL_KEYDOWN ) break;
    if ( event.type == SDL_QUIT ) break;
}
return 0;

}
-------------- next part --------------
A non-text attachment was scrubbed…
Name: RLEaccel.diff
Type: application/octet-stream
Size: 876 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021008/81f410d5/attachment.obj

It crashes in SDL_RLEAlphaBlit() because the destination is an
RLE surface that hasn’t had SDL_UnRLESurface() called on it.

This led to the enclosed patch.

[snipped]

Thanks John and Paolo!
I’ve looked at the problem and a fix is in CVS:
http://www.libsdl.org/cvs.php
Please let me know if it works for you. :slight_smile:

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