Date: Sat, 13 May 2006 15:50:33 +0900 (JST) Message-Id: <20060513.155033.18309628.garrigue at math.nagoya-u.ac.jp> To: oandrieu at nerim.net Cc: ketty at zzz.g.la, lablgtk at math.nagoya-u.ac.jp Subject: Re: Bug report... From: Jacques Garrigue In-Reply-To: <17497.1818.852757.874395 at karryall.dnsalias.org> References: <55113.192.168.2.12.1146509805.squirrel at zzz.g.la> <17497.1818.852757.874395@karryall.dnsalias.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: Text/Plain; charset=us-ascii Content-Length: 1829 From: Olivier Andrieu > ketty@zzz.g.la [Monday 1 May 2006] : > > > > (* Hi, this is a very weird and anoying segfault i am getting with > > * lablgtk2. My version of lablgtk2 is 20040716#7 that comes with godi, > > * and ocaml is 3.09.1.. > > OK, I had a look and it looks like a bug in the bytecode runtime (the > native code version runs fine for me). I've submitted a bug report on > the OCaml bugtracker (#4014). The bug report was rejected as standard behaviour: finalization functions should never trigger callbacks. Here is a patch that should solve the problem. (A more complete one is in CVS.) Note that this means that no garbage collection can be done on GObject's if there is no main loop running. Jacques Index: src/ml_gobject.c =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/ml_gobject.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- src/ml_gobject.c 30 Jun 2005 07:54:36 -0000 1.30 +++ src/ml_gobject.c 13 May 2006 06:43:44 -0000 1.31 @@ -17,8 +17,18 @@ /* gobject.h */ -Make_Val_final_pointer(GObject, g_object_ref, g_object_unref, 0) -Make_Val_final_pointer_ext (GObject, _new, Ignore, g_object_unref, 20) +static gboolean ml_g_object_unref0 (gpointer p) +{ g_object_unref((GObject*)p); return 0; } + +CAMLprim void ml_g_object_unref_later (GObject *p) +{ + g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, ml_g_object_unref0, + (gpointer)(p), NULL); +} + + +Make_Val_final_pointer(GObject, g_object_ref, ml_g_object_unref_later, 0) +Make_Val_final_pointer_ext (GObject, _new, Ignore, ml_g_object_unref_later, 20) ML_1 (G_TYPE_FROM_INSTANCE, GObject_val, Val_int) // ML_1 (g_object_ref, GObject_val, Unit) CAMLprim value ml_g_object_unref (value val)