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 139567 - Detection of RTLD_GLOBAL is broken
Detection of RTLD_GLOBAL is broken
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.4.x
Other other
: High major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 140329
 
 
Reported: 2004-04-09 10:09 UTC by Julio Merino
Modified: 2011-02-18 16:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample patch (827 bytes, patch)
2004-04-09 10:10 UTC, Julio Merino
none Details | Review
Patch that creates a test library (1.50 KB, patch)
2004-05-02 18:19 UTC, Julio Merino
none Details | Review

Description Julio Merino 2004-04-09 10:09:01 UTC
The configure script has a check to see if RTLD_GLOBAL works properly or not. 
This check does not work, because it detects that RTLD_GLOBAL doesn't work
properly under NetBSD, while it does.  The problems of this are exposed later in
other libraries using glib (specially, I got crazy to see why gstreamer did not
work at all on my computer).

Why the check breaks... well, it uses libpthread.so as a test case.  In NetBSD,
this library can't be loaded at runtime by a non-threaded application.  That is,
if you have a program that's not linked with libpthread, opening a module at
runtime that uses it results in a coredump.  This is because the program startup
code is different for threaded applications.  So, the check in configure breaks,
and glib is built without RTLD_GLOBAL support (a thing that you won't notice
until it's very late).  Eww.

I've fixed it by changing the check to use 'libintl' as a test case (which is
required anyway by glib).  It works.  This is what has been done in pkgsrc (the
NetBSD packaging system) to fix this issue:

    http://mail-index.netbsd.org/pkgsrc-changes/2004/04/06/0004.html

The attached patch does the same.

Furthermore, it could be a good idea to show a big warning from glib when a
program tries to g_module_load a library with global binding, if it's not
available (because the application won't work, probably).
Comment 1 Julio Merino 2004-04-09 10:10:25 UTC
Created attachment 26514 [details] [review]
Sample patch
Comment 2 Matthias Clasen 2004-04-23 14:56:09 UTC
The problem with this approach is that libintl is not actually required by glib
on all platforms. This linux box doesn't have it, for example, since gnu libc
includes the gettext functionality...
Comment 3 Julio Merino 2004-04-23 15:06:49 UTC
Ew... so which library could be a good candidate for testing?

Another approach could be to build a loadable plugin from the configure script,
and then use that to do the dlopen test...  It seems that libtool is already
available at that point, so the plugin could be built in a portable way.
Comment 4 Matthias Clasen 2004-04-23 15:15:38 UTC
I don't know a good candidate. Building a small test library just for the test
might be the best option, but it is a bit more work, of course...and you'll have
to deal with locating the uninstalled library.
Comment 5 Julio Merino 2004-05-02 18:19:26 UTC
Created attachment 27308 [details] [review]
Patch that creates a test library

This patch creates a small plugin (using libtool) to issue the RTLD_GLOBAL
test.  Don't know if it's completely right... but works :P