SDL Crashing

Hi,

I have a problem with SDL under Windows98. The target machine is a

566Cel, 256MB RAM, V3-3000. The code has compiled on my other development
machines (Win2k, 1GigP3, GF2MX400, 512MB RAM and win2k, XP1700, GF2MX400,
512MB RAM), but crashes on my Win98 box. I am using the getpixel routine as
posted in the SDL docs with a few bounds checking functions, but it remains
essentially unmodified. The surface is of course locked before calling
getpixel.

I am loading 24bpp bitmaps onto a surface and copying them to the screen

using custom wipe effects (like power point). When I compiled the wipe demo
on the Win98 machine though, the getpixel routine is failing and crashing
the program by returning a pointer that doesn’t point to anything. The error
occurs at the last row of pixels (x=N, y = 480). The funny thing is, the
error doesn’t occur until x=122, y=480 while the function is traversing the
last row getting pixels. The actual error occurs when I try and dereference
the pointer to the pixel. If I just skip the last row, everything works
fine.

Please Advise

Dan

I am loading 24bpp bitmaps onto a surface and copying them to the screen

using custom wipe effects (like power point). When I compiled the wipe demo
on the Win98 machine though, the getpixel routine is failing and crashing
the program by returning a pointer that doesn’t point to anything. The error
occurs at the last row of pixels (x=N, y = 480). The funny thing is, the
error doesn’t occur until x=122, y=480 while the function is traversing the
last row getting pixels. The actual error occurs when I try and dereference
the pointer to the pixel. If I just skip the last row, everything works
fine.

If you have an image 640x480, the valid range of x and y are:
{0 - 639}, {0 - 479}
When you ask for x = N and y = 480, you are reading beyond the last
row of the image, and will get bad data or crash.

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

Duh… (Sorry, I must not have had enough coffee yet today). I wonder why
it worked on the other platforms.> ----- Original Message -----

From: slouken@devolution.com (Sam Lantinga)
To:
Sent: Friday, May 10, 2002 4:49 PM
Subject: Re: [SDL] SDL Crashing

I am loading 24bpp bitmaps onto a surface and copying them to the

screen

using custom wipe effects (like power point). When I compiled the wipe
demo

on the Win98 machine though, the getpixel routine is failing and
crashing

the program by returning a pointer that doesn’t point to anything. The
error

occurs at the last row of pixels (x=N, y = 480). The funny thing is, the
error doesn’t occur until x=122, y=480 while the function is traversing
the

last row getting pixels. The actual error occurs when I try and
dereference

the pointer to the pixel. If I just skip the last row, everything works
fine.

If you have an image 640x480, the valid range of x and y are:
{0 - 639}, {0 - 479}
When you ask for x = N and y = 480, you are reading beyond the last
row of the image, and will get bad data or crash.

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


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

Duh… (Sorry, I must not have had enough coffee yet today). I wonder why
it worked on the other platforms.

You just got lucky with the memory layout. :slight_smile:

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