Crash On Exit

My program is Segfaulting on exit, but only when I press a key when the
program is running, I have removed all keyboard handling from the
program. The stack is as follows:

#0 0x400e34de in __libc_free (mem=0x805f8b8) at malloc.c:2921
#1 0x40238dbd in XkbFreeClientMap ()
#2 0x4023b059 in XkbFreeKeyboard ()
#3 0x4022fc07 in _XkbFreeInfo ()
#4 0x401fe038 in _XFreeDisplayStructure ()
#5 0x401ef7c7 in XCloseDisplay ()
#6 0x4019f2eb in SDL_SYS_VideoQuit (screen=0x8053e10) at
#7 0x40199307 in SDL_VideoQuit () at SDL_video.c:628
#8 0x40183ec2 in _SDL_Quit () at SDL.c:109
#9 0x804b831 in SDL_Quit () at MessageArea.cpp:22
#10 0x400ab5a6 in exit (status=1) at exit.c:55
#11 0x400a2cb9 in __libc_start_main () at

any ideas? (The pointer passed to SDL_SYS_VideoQuit is valid)


I noticed one other thing, not quite sure if this is relevant, but the
display window is still displayed after the unmap window call. I only
disappears on the call to XCloseDisplay which is what causes the crash.