Subject: Re: bug#59365: make-dynamic-linker-cache OOMs for LLVM 15 on i686-linux

From: Ludovic Courtès <[email-masked]>
Date: Thu, 03 Apr 2025 23:30:21 +0200

Hi,

Ludovic Courtès <[email-masked]> skribis:

> diff --git a/guix/build/gremlin.scm b/guix/build/gremlin.scm
> index 2a74d51dd9..8a38dde1eb 100644
> --- a/guix/build/gremlin.scm
> +++ b/guix/build/gremlin.scm
> @@ -250,7 +250,11 @@ (define (file-dynamic-info file)
>  info."
>    (call-with-input-file file
>      (lambda (port)
> -      (elf-dynamic-info (parse-elf (get-bytevector-all port))))))
> +      (elf-dynamic-info (parse-elf
> +                         ;; Read at most 10 MiB in memory, which should be
> +                         ;; enough to get the PT_DYNAMIC segment.
> +                         ;; TODO: mmap the whole file instead.
> +                         (get-bytevector-n port (* 10 (expt 2 20))))))))
>  

I was pondering whether to include it on the ‘core-packages-team’
branch, and the answer is no: I quickly found a counterexample where
this hack breaks badly:

--8<---------------cut here---------------start------------->8---
scheme@(guix build gremlin)> (file-dynamic-info "/home/ludo/.guix-home/profile/lib/libgs.so")
ice-9/boot-9.scm:1683:22: In procedure raise-exception:
ERROR:
  1. &invalid-segment-size:
      elf: #<<elf> bytes: #vu8(127 69 76 70 2 1 1 0 0 0 0 0 0 0 0 0 3 0 62 0 1 0 0 0 0 0 …
--8<---------------cut here---------------end--------------->8---

… where:

--8<---------------cut here---------------start------------->8---
$ du -hsL ~/.guix-home/profile/lib/libgs.so
22M	/home/ludo/.guix-home/profile/lib/libgs.so
$ readlink -f ~/.guix-home/profile/lib/libgs.so
/gnu/store/h63c568fnky1kjdk00q5clsba9icg88n-ghostscript-9.56.1/lib/libgs.so.9.56
--8<---------------cut here---------------end--------------->8---

Ludo’.