GNU bug report logs - #21076
dynamic-link often fails to load libraries

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Frank Webster <f.webster@HIDDEN>; dated Thu, 16 Jul 2015 17:05:02 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 21076 <at> debbugs.gnu.org:


Received: (at 21076) by debbugs.gnu.org; 16 Jul 2015 23:00:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 16 19:00:36 2015
Received: from localhost ([127.0.0.1]:51477 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZFs8p-00016V-BH
	for submit <at> debbugs.gnu.org; Thu, 16 Jul 2015 19:00:36 -0400
Received: from mout.gmx.net ([212.227.17.20]:54396)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <a.rottmann@HIDDEN>) id 1ZFs8l-0000zF-Rf
 for 21076 <at> debbugs.gnu.org; Thu, 16 Jul 2015 19:00:33 -0400
Received: from delenn.home.rotty.xx.vu ([91.119.182.207]) by mail.gmx.com
 (mrgmx102) with ESMTPSA (Nemesis) id 0Lyj4F-1Yvwgo2OuN-0167Ls; Fri, 17 Jul
 2015 01:00:25 +0200
Received: by delenn.home.rotty.xx.vu (Postfix, from userid 1000)
 id D0B1D321428; Fri, 17 Jul 2015 01:00:23 +0200 (CEST)
From: Andreas Rottmann <a.rottmann@HIDDEN>
To: Frank Webster <f.webster@HIDDEN>
Subject: Re: bug#21076: dynamic-link often fails to load libraries
References: <2096431437065554@HIDDEN>
Date: Fri, 17 Jul 2015 01:00:23 +0200
In-Reply-To: <2096431437065554@HIDDEN> (Frank Webster's message of
 "Thu, 16 Jul 2015 19:52:34 +0300")
Message-ID: <87r3o7pv20.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/pl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bugs-Envelope-To: 21076
Cc: 21076 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Frank Webster <f.webster@HIDDEN> writes:

> On my Debian system, `dynamic-link' often fails to load shared
> libraries:
>
> Loading using a versioned soname never works:
>
> scheme@(guile-user)> (dynamic-link "libGL.so.1")
> ERROR: In procedure dynamic-link:
> ERROR: In procedure dynamic-link: file: "libGL.so.1", message: "file not found"
>
> Loading without a library extension doesn't work unless the
> corresponding *-dev package is installed:
>
> scheme@(guile-user)> (dynamic-link "libGL")
> ERROR: In procedure dynamic-link:
> ERROR: In procedure dynamic-link: file: "libGL", message: "file not found"
>
> It is supposed to work with or without the extension, however because
> of limitations in the underlying lt_dlopenext function in libtool,
> neither works.
>
I'd argue that using the second variant (or using `(dynamic-link
"libGL.so")') is kinda inherently broken in an application loading
general-use (public) shared libraries, as opposed to plugins specific to
an application: you have no idea what ABI the library you just loaded
has. This means you may later use of symbols from that library in a way
that violates the ABI.

Unfortunatly, how the ABI is encoded into the shared library name is
platform-dependent, and this is also (as I read between the lines of the
bug thread referenced by you [0]) one of the reasons why the libtool
developers are not sure how a solution to this problem should look
like.

I think to write an application that is somewhat protected against ABI
changes, you need to have a mapping from ABIs supported by your
application to shared library file names (including the version
extension). You might have only one supported ABI, but the mapping is
still platform-dependent, so you have to either have a run-time or
build/install-time switch choosing the appriopriate shared library name.

Now, to make matters worse, you can't do that using libltdl, as you
noticed:

> The first doesn't work because contrary to its
> documentation, lt_dlopenext doesn't always try loading
> the bare filename first, without appending an extention.
>
Yes, this is a really annoying bug, and is what kept me from (trying to)
port sbank[1] (a gobject-introspection binding) to Guile a few years
back. In gobject-introspection, you get the full shared library file
name, along with a machine-readable ABI description, but you can't open
the shared library using the versioned name in Guile.

[1] https://github.com/rotty/sbank

> The second doesn't work because the versioned soname extension (.so.1)
> isn't among the ones that lt_dlopenext tries to append. It does try the
> unversioned extension (.so), but in Debian the unversioned symlink
> is only available when the corresponding *-dev package is installed.
>
Yeah, but IMHO, this kind of use with a bare shared library name
(without SONAME/ABI information) is already misguided in the first
place, unless you have some other way of knowing the ABI. Debian and the
likes not installing .so files (or .la files) by default only exposes
the inherent potential breakage.

[0]
> Here is a related libtool bug report: https://debbugs.gnu.org/8976
>
> Note that there are arguably two distinct issues:
> (1) lt_dlopenext not trying the bare filename in all cases
> (2) lt_dlopenext not trying versioned soname extensions.
>
> Obviously one way to address this would be to fix these two issues in
> lt_dlopenext in libtool.
>
As mentioned, solving problem (2) is not a good idea IMO -- the versions
are there for a reason, and you cannot (should not) guess them.

> Alternatively, the (system foreign) module in guile could provide a
> simple low-level wrapper around lt_dlopen, and possibly implement
> the higher level functionality of `dynamic-link' (additional search
> paths, guessing extensions etc.) in scheme.
>
+1

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.xx.vu/>




Information forwarded to bug-guile@HIDDEN:
bug#21076; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Jul 2015 17:04:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 16 13:04:39 2015
Received: from localhost ([127.0.0.1]:51346 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZFmaM-0000m9-US
	for submit <at> debbugs.gnu.org; Thu, 16 Jul 2015 13:04:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:32967)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOv-0000U8-NZ
 for submit <at> debbugs.gnu.org; Thu, 16 Jul 2015 12:52:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOp-00051g-H8
 for submit <at> debbugs.gnu.org; Thu, 16 Jul 2015 12:52:44 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:60305)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOp-00051c-E9
 for submit <at> debbugs.gnu.org; Thu, 16 Jul 2015 12:52:43 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46467)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOo-0003Bw-Co
 for bug-guile@HIDDEN; Thu, 16 Jul 2015 12:52:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOk-00050T-CK
 for bug-guile@HIDDEN; Thu, 16 Jul 2015 12:52:42 -0400
Received: from forward19m.cmail.yandex.net ([5.255.216.150]:36255)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <f.webster@HIDDEN>) id 1ZFmOk-0004zg-1k
 for bug-guile@HIDDEN; Thu, 16 Jul 2015 12:52:38 -0400
Received: from web11m.yandex.ru (web11m.yandex.ru [IPv6:2a02:6b8:0:2519::211])
 by forward19m.cmail.yandex.net (Yandex) with ESMTP id 7811520773
 for <bug-guile@HIDDEN>; Thu, 16 Jul 2015 19:52:35 +0300 (MSK)
Received: from 127.0.0.1 (localhost [127.0.0.1])
 by web11m.yandex.ru (Yandex) with ESMTP id E461C2F216F3;
 Thu, 16 Jul 2015 19:52:34 +0300 (MSK)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail;
 t=1437065555; bh=sZXZisPAgTE6FYBp74ETC7AVR3oFSVp95CiTSK5xyX4=;
 h=From:To:Subject:Date;
 b=Vx4yl2tAbeJLRVfQquR84c9FEFdjn3weDaw3PcbON52qPvfAzEt1SJe/KCViqAJBw
 Sss/6zwqL/aba+js9tD/GUwp54jeZZyvf7ZksN7PDtgbB1XNER4Xc7ejwIHcPOKAAs
 v+ytSMQqUa87MFN9FHre9RIJkbxR9SDVTEzA++LI=
Received: by web11m.yandex.ru with HTTP;
	Thu, 16 Jul 2015 19:52:34 +0300
From: Frank Webster <f.webster@HIDDEN>
Envelope-From: f-webster@HIDDEN
To: bug-guile@HIDDEN
Subject: dynamic-link often fails to load libraries
MIME-Version: 1.0
Message-Id: <2096431437065554@HIDDEN>
X-Mailer: Yamail [ http://yandex.ru ] 5.0
Date: Thu, 16 Jul 2015 19:52:34 +0300
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 16 Jul 2015 13:04:37 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

On my Debian system, `dynamic-link' often fails to load shared
libraries:

Loading using a versioned soname never works:

scheme@(guile-user)> (dynamic-link "libGL.so.1")
ERROR: In procedure dynamic-link:
ERROR: In procedure dynamic-link: file: "libGL.so.1", message: "file not found"

Loading without a library extension doesn't work unless the
corresponding *-dev package is installed:

scheme@(guile-user)> (dynamic-link "libGL")
ERROR: In procedure dynamic-link:
ERROR: In procedure dynamic-link: file: "libGL", message: "file not found"

It is supposed to work with or without the extension, however because
of limitations in the underlying lt_dlopenext function in libtool,
neither works.

The first doesn't work because contrary to its
documentation, lt_dlopenext doesn't always try loading
the bare filename first, without appending an extention.

The second doesn't work because the versioned soname extension (.so.1)
isn't among the ones that lt_dlopenext tries to append. It does try the
unversioned extension (.so), but in Debian the unversioned symlink
is only available when the corresponding *-dev package is installed.

Here is a related libtool bug report: https://debbugs.gnu.org/8976

Note that there are arguably two distinct issues:
(1) lt_dlopenext not trying the bare filename in all cases
(2) lt_dlopenext not trying versioned soname extensions.

Obviously one way to address this would be to fix these two issues in
lt_dlopenext in libtool.

Alternatively, the (system foreign) module in guile could provide a
simple low-level wrapper around lt_dlopen, and possibly implement
the higher level functionality of `dynamic-link' (additional search
paths, guessing extensions etc.) in scheme.




Acknowledgement sent to Frank Webster <f.webster@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#21076; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 16 Jul 2015 23:00:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.