Hi, now I have a problem. I have a GUI program that uses Gtk and build with Glade. And it has a menu bar in it. When I press a menu, it receives a signal and call a function from a rendering library which keeps looping and uses Cario surface to print something to a GtkImage widget.

In order to let GtkImage refresh to display what is in the Cario surface, I want to create another thread to keep the GUI active. So I use POSIX pthread functions to create a thread.
Code:
pthread_t id;
pthread_create ( &id, nullptr, RenderFramesLoop, nullptr );
Actually it works for a few second, but as soon as I move the mouse in that GUI window, it crashes and prints as following:

Code:
(X3dRenderLibrary:20185): Gdk-WARNING **: The program 'X3dRenderLibrary' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadLength (poly request too large or internal Xlib length erro'.
  (Details: serial 1131 error_code 16 request_code 29 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
So I look through Google and find that Gtk actually has some thread managing functions too. I haven't tried those functions yet, but I am confused. Why Gtk should have those functions ? What are the differences ? Does those functions could probably solve the crash ? And how could I use it properly ?

Thank you