I came across the GType registration problem. My program shows the below error message, resulting in crash. (process:3911): GLib-GObject-WARNING **: cannot register existing type `SoupSession' (process:3911): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed (process:3911): GLib-GObject-CRITICAL **: g_type_register_static: assertion `parent_type > 0' failed (process:3911): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed My program consists of main process with several shared objects which will be dynamically loaded in runtime. Any recommendation to avoid the crash ? I attached a simple example which makes the crash. // @main.c static int dlopen_hello() { void* handle = dlopen("./hello.so", RTLD_LAZY); typedef void (*hello_t)(); hello_t hello = (hello_t) dlsym(handle, "hello"); hello(); dlclose(handle); return 0; } int main() { g_type_init(); // can't move; must be here !!! if this will have moved to hello() in so.c, no crash is observable. dlopen_hello(); dlopen_hello(); dlopen_hello(); } ------------------------------------------------------------------------ // so.c void hello() { SoupSession* session = soup_session_async_new(); soup_session_abort (session); g_object_unref (session); return; } |