Delivered-To: garrigue at math.nagoya-u.ac.jp Delivered-To: lablgtk at yquem.inria.fr From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: lablgtk at yquem.inria.fr Date: Sat, 6 Feb 2010 05:30:16 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201002060530.16615.jon at ffconsultancy.com> Subject: [Lablgtk] Threading woes Status: U I'm trying to write a program that uses a UI thread for visualization and a worker thread to do computation. I had the problem that my worker thread was being blocked by something, preventing it from running. Digging, I discovered that LablGTK requires the use of a different "main" in the case of threaded code. I believe you are either supposed to compile GtkThInit.cmx into your project or copy its code: let thread = GtkThread.start () Judging by examples/GL/simple_th.ml: ... GtkThread.async w#show (); Thread.join GtkThInit.thread I'd say the GtkThread.start function was spawning a separate UI thread. So I've changed my code to: window#show(); Thread.join(GtkThread.start ()); and am compiling with: ocamlopt -annot -thread -I +lablgtk2 -I +lablgtkgl2 -I +lablgl lablgl.cmxa lablgtk.cmxa lablgtkgl.cmxa unix.cmxa threads.cmxa gtkThread.cmx x.ml -o x but when I run the resulting program I get a segfault: $ ./x (process:15948): GLib-GObject-WARNING **: invalid (NULL) pointer instance (process:15948): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed Segmentation fault What am I doing wrong? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk