Weird X-related backtrace

I just ported this app to gtk-2, and now I get a segfault when I close it while a file’s open. Check out this weird backtrace. Any ideas on how to resolve this are welcome.

(gdb) bt
#0 0x089921bb in ?? ()
#1 0xb6c0ebcd in XQueryExtension (dpy=0x8990df0, name=0xb72adb5d "GLX",
major_opcode=0x898d6d0, first_event=0x898d6d0, first_error=0x898d6d0)
at QuExt.c:46
#2 0xb6c01f2b in XInitExtension (dpy=0x8990df0, name=0xb72adb5d "GLX")
at InitExt.c:49
#3 0xb71c46d1 in XextAddDisplay (extinfo=0x82e7508, dpy=0x8990df0,
ext_name=0x898d6d0 " !\231\bI", hooks=0xb72b23a0, nevents=17,
data=0x898d6d0 " !\231\bI") at extutil.c:108
#4 0xb727bdb8 in __glXFindDisplay (dpy=0x8990df0) at glxext.c:329
#5 0xb727c535 in __glXInitialize (dpy=0x8990df0) at glxext.c:1104
#6 0xb727d73d in __glXSetupForCommand (dpy=0x8990df0) at glxext.c:1246
#7 0xb72787c6 in DestroyContext (dpy=0x8990df0, gc=0x82f4890) at glxcmds.c:458
#8 0xb7343dcc in gdk_gl_context_unref (context=0x82f4480) at gdkgl.c:192
#9 0xb734478c in gtk_gl_area_destroy (object=0x8762598) at gtkglarea.c:174
#10 0xb6aece1f in g_cclosure_marshal_VOID__VOID (closure=0x82a8700,
return_value=0x0, n_param_values=1, param_values=0x8990df0,
invocation_hint=0xbfa00ca8, marshal_data=0xb7344730) at gmarshal.c:77