Trying to understand why SDL_GetRGB() crashes

Dear All,

I keep running into situations where SDL_GetRGB() crashes my app (SIGSEGV).
I don’t understand why the call would crash; perhaps you can enlighten me
with your ideas.

Let’s assume that all 4 pointer arguments are correct; I’ve checked this
over and over again.
If the first ‘pixel’ argument is invalid then I would expect incorrect
results, but no crash.
I use the call on surfaces that I have previously loaded with images from
disk via IMG_Load().
It might have something to do with (BMP) images with indexed colours; it
doesn’t seem to happen with 24 bitmaps.

I use:

  • SDL-1.2.11
  • mingw
  • ms vista

Thanks,
Maarten Engels

Can you post some code for us to look at?> ----- Original Message -----

From: m.engels@visualproductions.nl (Maarten Engels)
To: sdl at lists.libsdl.org
Sent: Wednesday, 15 August, 2007 11:44:12 AM
Subject: [SDL] Trying to understand why SDL_GetRGB() crashes

Dear All,

I keep running into situations where SDL_GetRGB() crashes my app (SIGSEGV).
I don’t understand why the call would crash; perhaps you can enlighten me
with your ideas.

Let’s assume that all 4 pointer arguments are correct; I’ve checked this
over and over again.
If the first ‘pixel’ argument is invalid then I would expect incorrect
results, but no crash.
I use the call on surfaces that I have previously loaded with images from
disk via IMG_Load().
It might have something to do with (BMP) images with indexed colours; it
doesn’t seem to happen with 24 bitmaps.

I use:

  • SDL-1.2.11
  • mingw
  • ms vista

Thanks,
Maarten Engels


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

  ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maarten Engels - Visual Productions wrote:

Dear All,

I keep running into situations where SDL_GetRGB() crashes my app (SIGSEGV).
I don’t understand why the call would crash; perhaps you can enlighten me
with your ideas.

Let’s assume that all 4 pointer arguments are correct; I’ve checked this
over and over again.
If the first ‘pixel’ argument is invalid then I would expect incorrect
results, but no crash.
I use the call on surfaces that I have previously loaded with images from
disk via IMG_Load().
It might have something to do with (BMP) images with indexed colours; it
doesn’t seem to happen with 24 bitmaps.

I use:

  • SDL-1.2.11
  • mingw
  • ms vista

Thanks,
Maarten Engels

_

Hi, this is just a shot in the dark, and I hope I’m not wasting
bandwidth, but I wonder if perhaps the way you are calculating the
pixel’s position might be grabbing uninitialized memory… I did a
google and found this, might not be related to your problem, but could
be worth checking into…

Also, again a shot in the dark (it’s one of those mornings), does your
surface need to be locked first before accessing the pixel?

Jim

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGxZQwQuDJiZ/QrH0RApMMAJ9wQTov2ZGVqRjOEIYSZV6f2ZKUXwCfbrtL
TOYrqpYi8J1/XVuNmaQkj5w=
=+Tt4
-----END PGP SIGNATURE-----