Program crashes on exit

I have been laying out the framework for an SDL app, currently it
is very simple and does little, but I find that the program crashes
simply on calling SDL_Quit with:

Fatal signal: Segmentation Fault (SDL Parachute Deployed)

doing a stacktrace in gdb yields:

#0 0x40130dce in chunk_free (ar_ptr=0x401e2520, p=0x8053fd0) at
malloc.c:3242
#1 0x40130ba8 in __libc_free (mem=0x8054828) at malloc.c:3154
#2 0x4004b149 in X11_FreeWMCursor () from /usr/lib/libSDL-1.2.so.0
#3 0x4003e133 in SDL_FreeCursor () from /usr/lib/libSDL-1.2.so.0
#4 0x4003dc62 in SDL_CursorQuit () from /usr/lib/libSDL-1.2.so.0
#5 0x400436f2 in SDL_VideoQuit () from /usr/lib/libSDL-1.2.so.0
#6 0x40023169 in SDL_QuitSubSystem () from /usr/lib/libSDL-1.2.so.0
#7 0x400231cc in SDL_Quit () from /usr/lib/libSDL-1.2.so.0
#8 0x400e4ee2 in exit (status=1) at exit.c:54
#9 0x08049988 in handle_event (event=0x8054838) at flipout.cpp:40
#10 0x080499d7 in loop () at flipout.cpp:57
#11 0x08049ac8 in main () at flipout.cpp:95
#12 0x400d0306 in __libc_start_main (main=0x8049ab8 , argc=1,
ubp_av=0xbffff864, init=0x8049584 <_init>, fini=0x804ed60 <_fini>,
rtld_fini=0x4000d2dc <_dl_fini>, stack_end=0xbffff85c)
at …/sysdeps/generic/libc-start.c:129

I’m calling SDL_Quit via the atexit( SDL_Quit ) trick, currently the app
does nothing more than establish a window, enter a loop and handle simple
keyboard events. Any help would be welcome, thanks =)–

Cheers,
Tristan

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

mQGiBDsWFj8RBACFK46y4BEKTS4ZH7MI3Wa9fhw+UOfSFcQKAHvUM3yJLO2Jr54F
kneljWExWul3QbhDjfIWH5g2G3tGFz/a99RzL0H7rIRRT+q5/w94OiGG0I4a1IcZ
ZEBY5HM9ZTRCSwO5jYfbQMPjwv+AYePn8DvR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ce in chunk_free (ar_ptr=0x401e2520, p=0x8053fd0) at
malloc.c:3242
#1 0x40130ba8 in __libc_free (mem=0x8054828) at malloc.c:3154
#2 0x4004b149 in X11_FreeWMCursor () from /usr/lib/libSDL-1.2.so.0

Frequently, when parts of SDL like this crash, it usually signifies memory
corruption in your application.

It would be a good idea to run your program through ElectricFence and see
what happens.

Then, if you aren’t using the latest SDL from CVS, try that. If it STILL
breaks, debugging SDL would be in order, but like I said, this usually
means a bug in your app.

–ryan.