Blitting the framebuffer surface on itself

Hi there.

I’m working on a project and encountered what I think is a bug in SDL. Well it’s more like a missing validation. Due to a certain misthinking in our engine code design, we ended up blitting the main surface (returned by SDL_SetVideoMode) on another pointer variable with the same address value. If this caused a crash directly I wouldn’t complain, but this is something else. The thing worked just fine on WinXP and Linux Debian system, but on a computer with Win7 x64 installed I got instant crash. Debugging the application didn’t lead to the blit function, it was crashing at the first time I used a STL library container iterator after that blit, even though there was no error in their usage. I still can’t explain why. I eventually managed to isolate the crash to the blitting function by commenting stuff and finally noticed my error.

I even checked SDL_GetError and nothing was returned. It would be great to add a noob-proof check asserting that (src != dst) in debug mode, but I guess it’s not there because it would add a cost to performance?

That is actually supposed to be okay, and is probably this bug:
http://bugzilla.libsdl.org/show_bug.cgi?id=1090On Mon, Jan 18, 2010 at 8:18 PM, Dunge wrote:

Hi there.

I’m working on a project and encountered what I think is a bug in SDL. Well
it’s more like a missing validation. Due to a certain misthinking in our
engine code design, we ended up blitting the main surface (returned by
SDL_SetVideoMode) on another pointer variable with the same address value.
If this caused a crash directly I wouldn’t complain, but this is something
else. The thing worked just fine on WinXP and Linux Debian system, but on a
computer with Win7 x64 installed I got instant crash. Debugging the
application didn’t lead to the blit function, it was crashing at the first
time I used a STL library container iterator after that blit, even though
there was no error in their usage. I still can’t explain why. I eventually
managed to isolate the crash to the blitting function by commenting stuff
and finally noticed my error.

I even checked SDL_GetError and nothing was returned. It would be great to
add a noob-proof check asserting that (src != dst) in debug mode, but I
guess it’s not there because it would add a cost to performance?


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


-Sam Lantinga, Founder and CEO, Galaxy Gameworks