On Mon, 15 Jun 2009 19:17:54 +0200 Jannis Pohlmann <jannis xfce org> wrote: > Hey, > > is GTypeModule supposed to be thread-safe? I'm currently working on an > application with a plugin interface based on GTypeModule. The > application itself runs several threads which create objects of the > types exported by the GTypeModule. > > Now, if I wait long enough and give the application enough to work on, > I always end up with the same result: the application crashes with the > following error: > > GLib-GObject:ERROR:gtype.c:1135:type_data_ref_Wm: assertion failed: > (node->data->common.ref_count > 0) > > I suppose this is a race condition where one thread unref's the last > instance of a type exported by the GTypeModule and another tries to > create a new instance at about the same time. Please correct me if I'm > wrong here. I played with this a bit more and it seems it's not related to GTypeModule all. Even if I make the GModule resident and never unuse the GTypeModule, I still end up with this error. So the question is, is GType or at least g_object_new() thread-safe? Or if it's not, shouldn't it be? Excerpt of the backtrace of the above error: #3 0xb7ec0f17 in g_assertion_message () #4 0xb7ec14dd in g_assertion_message_expr () #5 0xb7f6458f in g_type_class_ref () #6 0xb7f49268 in g_object_newv () #7 0xb7f497b1 in g_object_new_valist () #8 0xb7f49920 in g_object_new () Any help would be greatly appreciated. Seems like I can reduce the risk of this error to appear by protecting parts of my code with mutexes but that still isn't 100% safe and it looks to me like this might be a bug in GObject/GType. Cheers, Jannis
Attachment:
signature.asc
Description: PGP signature