About the dll search algorithm of dlopen (patch-r3)

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Aug 30 13:35:00 GMT 2016

On Aug 29 11:24, Michael Haubenwallner wrote:
> Hi Corinna,
> On 08/26/2016 02:04 PM, Corinna Vinschen wrote:
> > On Aug 25 19:48, Michael Haubenwallner wrote:
> >> On 08/22/2016 08:37 PM, Corinna Vinschen wrote:
> >>> (*) Yuk!  Do we really, *really* want that?  The redirection from
> >>>     /usr/lib to /usr/bin is only done for system libs, and only because
> >>>     otherwise we had trouble starting Cygwin from CMD or the Explorer
> >>>     GUI "Run..." box.  We can't change this without breaking everything
> >>>     since we *do* depend on the Windows loader yet.
> >>>     
> >>>     However, as long as this is restricted to /usr/lib, /usr/bin, it's a
> >>>     closed system under control of "the distro".  If you extend this to
> >>>     *any* external path ending in "lib", isn't it inherently dangerous
> >>>     to automate this under the hood, without the application's consent?
> >>>     Or, FWIW, the user's consent in case of LD_LIBRARY_PATH?
> >>
> >> 've split into add_lib_searchdir (), used for "/usr/lib" only.
> > 
> > Btw., I just noticed something interesting, independently of your patch.
> > Consider the file /usr/bin/cygz.dll:
> > 
> > - dlopen (libz.so)            success
> > 
> > - dlopen (/usr/bin/libz.so)   success
> > 
> > - dlopen (/usr/lib/libz.so)   fails
> > 
> > That's pretty clear when looking through the code, but... wouldn't
> > it make sense to allow that?  If a path is given, and the path points
> > to /usr/lib, search the file in /usr/bin as well?
> Easy enough - but this should apply to any prefix IMO: While the
> application specific prefix often isn't /usr - but something like
> /usr/local or /opt/application, application specific libs may be
> built & installed with libtool or something similar as well - at
> least some tool that knows about installing the real dll into
> <app-prefix>/bin (because of the missing Cygwin loader).

You have a point there.

> But agreed, it makes sense doing /lib->/bin for the explicit path and
> the /usr/lib default only and not for the environment-provided paths.

It feels certainly more safe to restrict this to the system path for
now.  But... yeah, you have a point.

Not well thought out, just an idea kicking around:

Apart from the obvious system path handling, what if other lib->bin
transitions only take place if the calling application is installed
in that very bin dir...?


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20160830/b59e9d61/attachment.sig>

More information about the Cygwin-developers mailing list