NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/49791: dlopen(0, and dlopened libraries

The following reply was made to PR lib/49791; it has been noted by GNATS.

From: Joerg Sonnenberger <>
Subject: Re: lib/49791: dlopen(0, and dlopened libraries
Date: Sat, 4 Apr 2015 20:49:57 +0200

 On Sat, Apr 04, 2015 at 06:35:01PM +0000, Patrick Welche wrote:
 >  So maybe this is the way forward. How do you decide on "correct"?
 >  Could you give me some pointers to why RTLD_GLOBAL is a bug, and the
 >  problems with subsequent dlclose()?
 The POSIX behavior makes no sense in light of multi-threaded programs.
 Returning a handle gives the illusion that the result of two consecutive
 calls will be the same, when a different thread might have done a
 dlopen or dlclose in the mean time. If the return value is supposed to
 be a magic global object, RTLD_DEFAULT is much saner as it doesn't
 pretend dlopen/dlclose is needed.
 The problem with RTLD_GLOBAL is that is (a) expensive and (b) dangerous.
 It is expensive because it adds work for every look-up the same way
 LD_PRELOAD does. It is dangerous because the meaning of a symbol changes
 over time. Especially noticable is that it can interact with lazy
 binding in surprising ways. There is broken software depending on such
 behavior (XFree86 and successors, I look at you!), but that is generally
 a sign of a very badly designed module system.

Home | Main Index | Thread Index | Old Index