Segmentation fault due to SDL_RLEACCEL (+sample program)

Hi all!

Using the latest SDL CVS Snapshot (Oct.3) and RedHat Linux 6.1, I get a
core dump after the following steps:

  • Create a surface from a BMP file (attached as cluster.spa.gz,
    important for reproducability)
  • Set the color key including SDL_RLEACCEL bit
  • Convert to display format
  • Blit the surface
  • Convert to display format a second time (don’t ask why I do that, it’s
    the core dump that counts :wink:

All works fine if I do either not use SDL_RLEACCEL, do not blit the
surface or do not make a second call to SDL_DisplayFormat.
The GNU Debugger info extracted from the core:

#0 0x4002ac21 in uncopy_32 (dst=0x40534000, src=0x404a7024, n=65535,
sfmt=0x404a7008, dfmt=0x804d8a8) at SDL_RLEaccel.c:1002
1002 PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a);

The sample program:

/* COMPILED USING RedHat Linux 6.1 AND SDL CVS SNAPSHOT FROM Oct.3 */
#include “SDL.h”

int main(int argc, char *argv[])
{ SDL_Surface *vga_surface,*surf;
SDL_Rect rect;
Uint32 transcol;

if (SDL_InitSubSystem(SDL_INIT_NOPARACHUTE|SDL_INIT_VIDEO)<0)
{ fprintf(stderr, “Couldn’t initialize SDL: %s\n”,SDL_GetError());
exit(1); }
vga_surface=SDL_SetVideoMode(1024,768,16,SDL_SWSURFACE);
surf=SDL_LoadBMP(“cluster.spa”);
transcol=SDL_MapRGB(surf->format,128,128,128);
/* THE SDL_RLEACCEL BELOW IS NEEDED TO GET A SEGMENTATION FAULT /
SDL_SetColorKey(surf,SDL_RLEACCEL,transcol);
surf=SDL_DisplayFormat(surf);
rect.x=rect.y=0;
rect.w=surf->w;
rect.h=surf->h;
/
THE BLIT BELOW IS ALSO NEEDED TO GET A SEGMENTATION FAULT /
SDL_BlitSurface(surf,&rect,vga_surface,&rect);
/
THE SDL_DisplayFormat BELOW CAUSES A SEGM.FAULT IF SDL_RLEACCEL HAS
BEEN SET */
surf=SDL_DisplayFormat(surf);
return(0); }

As an SDL newbee, I couldn’t trace the problem any further… Sorry.

Greetinx,
Elmar

P.S.: SDL is great. YEAH!
If the 6KB attachment “cluster.spa.gz” is missing, please contact me:
elmar at cmbi.kun.nl
-------------- next part --------------
A non-text attachment was scrubbed…
Name: cluster.spa.gz
Type: application/x-gzip
Size: 6672 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20001012/8134e8b6/attachment.bin

In article <39E5A6C2.47B9984E at cmbi.kun.nl>, elmar.krieger at cmbi.kun.nl says…

Hi all!

Using the latest SDL CVS Snapshot (Oct.3) and RedHat Linux 6.1, I get a
core dump after the following steps:

  • Create a surface from a BMP file (attached as cluster.spa.gz,
    important for reproducability)
  • Set the color key including SDL_RLEACCEL bit
  • Convert to display format
  • Blit the surface
  • Convert to display format a second time (don’t ask why I do that, it’s
    the core dump that counts :wink:

All works fine if I do either not use SDL_RLEACCEL, do not blit the
surface or do not make a second call to SDL_DisplayFormat.

this is a know issue which has been addressed recently.

As an SDL newbee, I couldn’t trace the problem any further… Sorry.

don't worry too much, it was a nasty bug. nice work reproducing it; it 

really helps!

-dv