guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] foreign-library: fix RTLD_LAZY | RTLD_LOCAL crash on macOS


From: Aleix Conchillo Flaqué
Subject: Re: [PATCH] foreign-library: fix RTLD_LAZY | RTLD_LOCAL crash on macOS
Date: Sun, 26 Sep 2021 21:45:08 -0700

Ignore. The issue was the way libgcrypt was linked in macOS.

See: https://dev.gnupg.org/T5610

A libgcrypt's libtool.m4 patch has been applied upstream.

On Sat, Sep 11, 2021 at 10:10 PM Aleix Conchillo Flaqué
<aconchillo@gmail.com> wrote:
>
> * module/system/foreign-library.scm (load-foreign-library): On macOS
> calling `dlopen` with RTLD_LAZY | RTLD_LOCAL causes a crash when calling
> `dlsym`. There are a three working combinations:
>
> - Using RTLD_NOW | RTLD_LOCAL
> - Using RTLD_NOW | RTLD_GLOBAL
> - Using RTLD_LAZY | RTLD_GLOBAL
>
> For efficiency purposes we choose RTLD_LAZY | RTLD_GLOBAL.
>
> See https://lists.gnu.org/archive/html/guile-devel/2021-09/msg00008.html
> ---
>  module/system/foreign-library.scm | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/module/system/foreign-library.scm 
> b/module/system/foreign-library.scm
> index dc426385f..63889277c 100644
> --- a/module/system/foreign-library.scm
> +++ b/module/system/foreign-library.scm
> @@ -172,6 +172,11 @@ name."
>           (else
>            name)))))
>
> +;; In macOS using dlopen with RTLD_LAZY | RTLD_LOCAL produces a crash.
> +;; https://lists.gnu.org/archive/html/guile-devel/2021-09/msg00008.html
> +(define system-needs-global?
> +  (string-contains %host-type "-darwin"))
> +
>  (define* (load-foreign-library #:optional filename #:key
>                                 (extensions system-library-extensions)
>                                 (search-ltdl-library-path? #t)
> @@ -186,7 +191,7 @@ name."
>                 #f))
>    (define flags
>      (logior (if lazy? RTLD_LAZY RTLD_NOW)
> -            (if global? RTLD_GLOBAL RTLD_LOCAL)))
> +            (if (or global? system-needs-global?) RTLD_GLOBAL RTLD_LOCAL)))
>    (define (dlopen* name) (dlopen name flags))
>    (if (and rename-on-cygwin? (string-contains %host-type "cygwin"))
>        (set! filename (lib->cyg filename)))
> --
> 2.33.0
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]