GNOME Bugzilla – Bug 710096
gtk3.10 doesn't work correctly when used from a dynamic library
Last modified: 2015-02-24 11:21:02 UTC
compile and run the provided test app and dynamic lib like this: gcc -shared dll.c `pkg-config --cflags --libs gtk+-3.0` -o dll.so gcc rundll.c -ldl -o rundll ./rundll gtk will not be able to create the about dialog (prints the errors in console). but it works if you compile and run like this gcc dll.c `pkg-config --cflags --libs gtk+-3.0` -o nodll ./nodll this only started in gtk3.10, but worked fine in all previous versions of gtk2 and gtk3. was tested on Fedora20 beta, archlinux after gtk3.10 update, opensuse 13.1 beta, and ubuntu 13.10 beta. this is a huge regression, as it not just breaks my application for all gtk3.10 users, but also makes it impossible to fix in any way without upstream fix.
Created attachment 257249 [details] app which loads and runs the dynamic lib
Created attachment 257250 [details] the dynamic lib itself
Created attachment 257255 [details] [review] GtkAboutDialog: Add missing calls to g_type_ensure() for used types If nothing else used these types then the template instantiation will fail.
Ok, here is the issue: Some new widgets use the new template system which requires a typename to GType lookup to work, for instance it needs to resolve "GtkBox". This works if either some code previously used referenced the GtkBox GType, or if dlsym() can lookup gtk_box_get_type(). In the nodll case the dlsym() succeeds, but in the rundll case it does not, because there gtk+ was loaded using RTLD_LOCAL (the default) instead of RTLD_GLOBAL. The solution is either to have each widget ensure_type each type they use, which seems a bit fragile, or have some better fallback (at least for the built in types).
Created attachment 257259 [details] [review] GtkBuilder: Fall back to gtk_test_register_all_types if type lookup fails This is important because the dlsym() approach can fail if gtk was loaded with RTLD_LOCAL.
Attachment 257255 [details] pushed as ad963d1 - GtkAboutDialog: Add missing calls to g_type_ensure() for used types Attachment 257259 [details] pushed as 0f9ce28 - GtkBuilder: Fall back to gtk_test_register_all_types if type lookup fails
confirmed fixed in gtk 3.10.2. many thanks from all deadbeef users, and from me!