After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 710096 - gtk3.10 doesn't work correctly when used from a dynamic library
gtk3.10 doesn't work correctly when used from a dynamic library
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.10.x
Other Linux
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-10-14 12:25 UTC by Alexey Yakovenko
Modified: 2015-02-24 11:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
app which loads and runs the dynamic lib (235 bytes, text/plain)
2013-10-14 12:26 UTC, Alexey Yakovenko
  Details
the dynamic lib itself (268 bytes, text/plain)
2013-10-14 12:26 UTC, Alexey Yakovenko
  Details
GtkAboutDialog: Add missing calls to g_type_ensure() for used types (1.62 KB, patch)
2013-10-14 13:39 UTC, Alexander Larsson
committed Details | Review
GtkBuilder: Fall back to gtk_test_register_all_types if type lookup fails (1.14 KB, patch)
2013-10-14 14:07 UTC, Alexander Larsson
committed Details | Review

Description Alexey Yakovenko 2013-10-14 12:25:40 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.
Comment 1 Alexey Yakovenko 2013-10-14 12:26:11 UTC
Created attachment 257249 [details]
app which loads and runs the dynamic lib
Comment 2 Alexey Yakovenko 2013-10-14 12:26:53 UTC
Created attachment 257250 [details]
the dynamic lib itself
Comment 3 Alexander Larsson 2013-10-14 13:39:35 UTC
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.
Comment 4 Alexander Larsson 2013-10-14 14:02:03 UTC
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).
Comment 5 Alexander Larsson 2013-10-14 14:07:02 UTC
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.
Comment 6 Matthias Clasen 2013-10-16 01:41:07 UTC
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
Comment 7 Alexey Yakovenko 2013-10-19 21:20:14 UTC
confirmed fixed in gtk 3.10.2. many thanks from all deadbeef users, and from me!