all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philippe SWARTVAGHER <philippe.swartvagher@inria.fr>
To: 54557@debbugs.gnu.org
Subject: bug#54557: “fakechroot” execution engine doesn’t work for Bash
Date: Fri, 25 Mar 2022 11:16:13 +0100	[thread overview]
Message-ID: <de5ac5be-d6a2-1c21-4a1f-223281dc0b2c@inria.fr> (raw)
In-Reply-To: <87sfr79i9j.fsf@inria.fr>


Le 24/03/2022 à 22:02, Ludovic Courtès a écrit :
> Hello!
>
> The “fakechroot” engine fails when applied to ‘bash’:
>
> --8<---------------cut here---------------start------------->8---
> $ guix pack -RR bash -S /bin=bin
> /gnu/store/mnbmklbvd1pk7yby0k8h26msk6z11m1m-bash-tarball-pack.tar.gz
> $ (cd /tmp/pack; tar xf /gnu/store/mnbmklbvd1pk7yby0k8h26msk6z11m1m-bash-tarball-pack.tar.gz)
> $ unshare -mrf sh -c 'mount -t tmpfs -o ro none /gnu/store; GUIX_EXECUTION_ENGINE=fakechroot /tmp/pack/bin/bash --version'
> /tmp/pack/gnu/store/d99ykvj3axzzidygsmdmzxah4lvxd6hw-bash-5.1.8/bin//bash: out of memory to store relocation results for /tmp/pack/bin/bash
> --8<---------------cut here---------------end--------------->8---
>
> The message comes from ld.so.  My guess is that the problem comes from
> Bash’s terrible ‘malloc’ replacement:
>
> --8<---------------cut here---------------start------------->8---
> $ objdump -T /gnu/store/d99ykvj3axzzidygsmdmzxah4lvxd6hw-bash-5.1.8/bin/bash | grep malloc
> 00000000004ae6f0 g    DF .text	000000000000003b  Base        malloc_usable_size
> 00000000004ae850 g    DF .text	0000000000000009  Base        malloc
> 0000000000484e70 g    DF .text	000000000000005b  Base        xmalloc
> 00000000004ee020 g    DO .bss	0000000000000004  Base        malloc_trace_at_exit
> 00000000004e8c24 g    DO .data	0000000000000004  Base        malloc_mmap_threshold
> 0000000000484f70 g    DF .text	00000000000000dd  Base        sh_xmalloc
> 00000000004f7a04 g    DO .bss	0000000000000004  Base        malloc_trace
> 00000000004f7a08 g    DO .bss	0000000000000004  Base        malloc_flags
> 00000000004ae730 g    DF .text	0000000000000005  Base        sh_malloc
> 00000000004f7a00 g    DO .bss	0000000000000004  Base        malloc_register
> 00000000004ae660 g    DF .text	000000000000000c  Base        _malloc_unblock_signals
> 00000000004ae630 g    DF .text	000000000000002e  Base        _malloc_block_signals
> --8<---------------cut here---------------end--------------->8---
>
> [Time passes…]  I confirmed this hypothesis by running:
>
>    guix pack -RR -S /bin=bin -m manifest.scm
>
> on this manifest:
>
> --8<---------------cut here---------------start------------->8---
> (use-modules (guix) (guix utils)
>               (guix profiles)
>               (gnu packages bash))
>
> (define bash-sans-malloc
>    (package/inherit bash
>      (name "bash-sans-malloc")
>      (arguments
>       (substitute-keyword-arguments (package-arguments bash)
>         ((#:configure-flags flags ''())
>          `(cons "--without-bash-malloc" ,flags))))))
>
> (packages->manifest (list bash-sans-malloc))
> --8<---------------cut here---------------end--------------->8---
>
> Works just fine:
>
> --8<---------------cut here---------------start------------->8---
> $ unshare -mrf sh -c 'mount -t tmpfs -o ro none /gnu/store; GUIX_EXECUTION_ENGINE=fakechroot /tmp/pack/bin/bash --version'
> GNU bash, version 5.1.8(1)-release (x86_64-unknown-linux-gnu)
> Copyright (C) 2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> --8<---------------cut here---------------end--------------->8---
>
> So in the end, it’s a bug report that’s kinda closed already.
>
> Perhaps we should build Bash ‘--without-bash-malloc’ unconditionally in
> ‘core-updates’?  The ‘INSTALL’ file reads:
>
> --8<---------------cut here---------------start------------->8---
> '--with-bash-malloc'
>       Use the Bash version of 'malloc' in the directory 'lib/malloc'.
>       This is not the same 'malloc' that appears in GNU libc, but an
>       older version originally derived from the 4.2 BSD 'malloc'.  This
>       'malloc' is very fast, but wastes some space on each allocation.
>       This option is enabled by default.  The 'NOTES' file contains a
>       list of systems for which this should be turned off, and
>       'configure' disables this option automatically for a number of
>       systems.
> --8<---------------cut here---------------end--------------->8---
>
> There might be other options if we want to keep it, such as changing the
> ELF visibility of those symbols, but I wonder if it’s worth the effort.
>
> Thoughts?
>
> Ludo’.

Hello,

FTR, the --without-bash-malloc is used in the Debian bash package:

apt source bash

cd bash-5.1/debian

grep -Irn without-bash-malloc
changelog:145:  * Configure the normal build --without-bash-malloc as well.
changelog:1125:  * Configure the static build --without-bash-malloc.
changelog:1462:  * Disable the GNU/kFreeBSD kludge 
(--without-bash-malloc). Closes: #234137.
changelog:1546:  * Configure --without-bash-malloc on GNU/FreeBSD 
(closes: #194182).
changelog:1739:  * Configure --without-bash-malloc. At least on hppa, 
this fixes an error,
rules:79:    --without-bash-malloc


This option is also advised in Linux From Scratch: 
https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bash.html

-- 
Philippe





  reply	other threads:[~2022-03-25 10:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 21:02 bug#54557: “fakechroot” execution engine doesn’t work for Bash Ludovic Courtès
2022-03-25 10:16 ` Philippe SWARTVAGHER [this message]
2022-03-28  6:59   ` Ludovic Courtès
2022-03-26  3:03 ` Maxim Cournoyer
2022-03-28 10:06   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de5ac5be-d6a2-1c21-4a1f-223281dc0b2c@inria.fr \
    --to=philippe.swartvagher@inria.fr \
    --cc=54557@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.