Gtk2 randomly crashes I have a small program in C that I wanted to add a GUI to, so after looking around I decided to use GTK+. I installed gtk2 using MacPorts (version installed was gtk2 @2.24.18_1+x11).

I am compiling my program with

gcc -Wall -Wextra -pendantic `pkg-config --libs --cflags gtk+-2.0` myprogram.c -lpthread -o myprogram


There are no errors during compilation, but when I run it, after some amount of time I will get random errors appearing such as:

Gdk:ERROR:gdkregion-generic.c:1110:void miUnionNonO(GdkRegion *, GdkRegionBox *, GdkRegionBox *, gint, gint): assertion failed: (y1 &lt; y2)

Gdk:ERROR:gdkregion-generic.c:337:void miSetExtents(GdkRegion *): assertion failed: (pExtents-&gt;y1 &lt; pExtents-&gt;y2)

Assertion failed: (ret != inval_id), function _XAllocID, file xcb_io.c, line 529.

Fatal IO error 35 (Resource temporarily unavailable) on X server /tmp/launch-7OAilk/org.macosforge.xquartz:0.

Assertion failed: (! xcb_xlib_unknown_req_in_deq), function dequeue_pending_request, file xcb_io.c, line 179.


It looks to me like these errors are caused by a bug in Gtk/Gdk/XQuartz, is there any easy way to fix this?

I am running OS X Mountain Lion 10.8.4, XCode 4.6.2, and XQuartz 2.7.4 (xorg-server 1.13.0).
This seems actually to just be a result of my poor programming. I was trying to perform drawing from a thread which was not the same thread that called Gtk_Main, resulting in undefined behaviour and the various error messages above.