Advertisement

Segmentation fault SDL_FreeSurface

Started by March 15, 2011 03:36 PM
2 comments, last by rip-off 13 years, 8 months ago
Hi everybody.

I'm so pissed off angry.gif...

(gdb) bt
#0 0xb7f3a6de in ?? () from /usr/lib/libSDL-1.2.so.0
#1 0xb7f3bbfd in SDL_FreeSurface () from /usr/lib/libSDL-1.2.so.0
...



Ok, lets see...


(gdb) up
#1 0xb7f3bbfd in SDL_FreeSurface () from /usr/lib/libSDL-1.2.so.0

(gdb) up
#2 0x080664f4 in ~Game (this=0x8125698, __in_chrg=<value optimized out>)
at src/game.cpp:302
302 SDL_FreeSurface(flat_);

(gdb) p flat_
$4 = (SDL_Surface *) 0x81261e0

(gdb) p *flat_
$5 = {flags = 65536, format = 0x1, w = 800, h = 600, pitch = 3200,
pixels = 0xb6874008, offset = 0, hwdata = 0x0, clip_rect = {x = 0, y = 0,
w = 800, h = 600}, unused1 = 0, locked = 0, map = 0x8126250,
format_version = 12, refcount = 0}



So what's the problem? Any idea?

Thank you very much.
Are you freeing the surface returned by SDL_SetVideoMode()? Don't do that, its a special surface, and is freed by SDL_Quit() or shutting down the SDL video subsystem.
Advertisement

Are you freeing the surface returned by SDL_SetVideoMode()? Don't do that, its a special surface, and is freed by SDL_Quit() or shutting down the SDL video subsystem.


Nop.

It's a SDL_Surface created with IMG_Load from a png. It's 800x600 but, like I said, it's not the screen surface.

wacko.gif

Thanks.
Has it already been passed to SDL_FreeSurface()? For example, if you made a copy of the Game object by accident and your game type does not follow the "Rule of Three".

The surface refcount is 0, which is suspicious (although it does depend on what order SDL handles the refcount).

This topic is closed to new replies.

Advertisement