SDL SDLSprite or src/video/SDL_blit_1 bug?

Hello, I’m using the memorychecker “efence” to debug my programm.

We have checked our program aggain and aggain, and we didin’t found
anything.
Is efence detecting errors in yours progams too ?

In ours, this happen after reading 1171 image .png without alpha, and
when we read 33 .png with alpha, then the 34th crashes.

Given “frameStream” here is the core loading code:
{
SDL_Surface *temp, *sprite;
temp=IMG_Load_RW(frameStream, 0);
assert(temp);
sprite=SDL_DisplayFormatAlpha(temp);
assert(sprite);
SDL_FreeSurface(temp);
images.push_back(sprite);
}

My computer:
-passed memtest, and this happend the same way on another.
-gcc version 3.2.3 20030422
-Gentoo Linux 1.4 3.2.3-r2
-kernel 2.4.22

(Efence lesson:
Efence places each malloc() in a different userspace, then this will use
a LOT of memory,
but has the advantage of using the virtual memory hardware, which is fast.
The drawback is that you can’t debug further if you did not solved
previous memory bug.)

Here is my backtarce:

(gdb) bt
#0 0x400b8e82 in Blit1to4Key (info=0xbffefbf0) at SDL_blit_1.c:399
#1 0x400b6049 in SDL_SoftBlit (src=0x43745fc4, srcrect=0xbffefcb8,
dst=0x43727fc4, dstrect=0xbffefcb8) at SDL_blit.c:108
#2 0x400cfc2d in SDL_LowerBlit (src=0x43745fc4, srcrect=0xbffefcb8,
dst=0x43727fc4, dstrect=0xbffefcb8) at SDL_surface.c:431
#3 0x400d07d1 in SDL_ConvertSurface (surface=0x43745fc4,
format=0x43539fd8, flags=0) at SDL_surface.c:856
#4 0x400d30dd in SDL_DisplayFormatAlpha (surface=0x43745fc4) at
SDL_video.c:951
#5 0x0813c619 in SDLSprite::loadFrame(SDL_RWops*, SDL_RWops*,
SDL_RWops*, SDL_RWops*) (this=0x4347d8c4, frameStream=0x436bdfe0,
overlayStream=0x0,
paletizedStream=0x0, rotatedStream=0x0) at SDLSprite.cpp:555
#6 0x081257b1 in SDLGraphicContext::loadSprite(char const*, char
const*) (this=0x40c97fe4, filename=0x8147982 “data/gfx/ressource”,
name=0x8147539 “ressources”) at SDLGraphicContext.cpp:1175
#7 0x0812629f in virtual thunk to SDLGraphicContext::loadSprite(char
const*, char const*) ()
#8 0x0808b9f7 in GlobalContainer::load() (this=0x40c83f88) at
GlobalContainer.cpp:339
#9 0x080893a2 in Glob2::run(int, char**) (this=0xbffff797, argc=1,
argv=0xbffff7e4) at Glob2.cpp:233
#10 0x08089c4f in main (argc=1, argv=0xbffff7e4) at Glob2.cpp:411
#11 0x403837a7 in __libc_start_main () from /lib/libc.so.6

Nuage wrote:

Hello, I’m using the memorychecker “efence” to debug my programm.

We have checked our program aggain and aggain, and we didin’t found
anything.
Is efence detecting errors in yours progams too ?

In ours, this happen after reading 1171 image .png without alpha, and
when we read 33 .png with alpha, then the 34th crashes.

You mean you’re loading more than 1000 pictures ?

Electric fence uses two memory pages more for each memory allocation
than standard memory allocation code does, so each malloc() has a high
associated cost.
I think you are simply running out of memory somewhere and not checking
return values.

Stephane