Re: bus error when use threads and native mode on Mac

Yoann Padioleau <[email protected]> Fri, 17 Sep 2010 10:00:46 +0000
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
On Sep 17, 2010, at 2:27 AM, Olivier Andrieu wrote:

> Hi,
> 
> On Fri, Sep 17, 2010 at 11:02, Yoann Padioleau <[email protected]> wrote:
>> Hi,
>> 
>> I am trying to use threads in my lablgtk application but it crashes (I am on Mac OS)
>> in native mode with a mysterious "Bus Error".
>> I have linked my program with -thread and use
>>  GtkThread.main ();
>> in the main but it does not work. It works nice in bytecode mode though.
>> 
>> My program displays some fancy graphics with cairo and then run in the background using a thread
>> some heavy computation that I access on demand from the main thread when the user click
>> on certain things.
>> 
>> My code also uses GMain.Idle and Gmain.Timeout (don't know if it's relevant).
> 
> It might ! Timeout and idle callbacks have different rules than the
> usual widget event callbacks wrt. threading.
> cf. http://library.gnome.org/devel/gdk/stable/gdk-Threads.html#gdk-Threads.description

Thanks. But why my program works in bytecode mode then, and not in native mode ?

BTW thanks for ocamlcairo :)

> 
>  « Idles, timeouts, and input functions from GLib, such as
> g_idle_add(), are executed outside of the main GTK+ lock. »
> 
> -- 
>  Olivier