Subject: bug#75658: Non-deterministic Gash error in ‘gcc-mesboot-4.9.4’

From: Ludovic Courtès <[email-masked]>
Date: Wed, 19 Mar 2025 22:27:15 +0100

Hello Timothy,

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

> The hack below addresses that (mostly) by reserving low-number file
> descriptors before the signal and finalization threads create their
> pipe.  (In practice, we can only reserve FDs above 5; FDs 3 and 4 are
> the “sleep pipe” I believe.)

I’ve just sent cleaned-up patches to gash-devel including this
fix/workaround.

It passes my tests, meaning that I cannot reproduce the original bug in
a timely fashion when running:

  ./pre-inst-env gash -c 'exec 2>/dev/null; while true; do echo $(sh --version) > /dev/null; done'

or when running part of the GCC 4.9.4 ‘configure’ script in a loop
(attached is the helper script I used for that; not shown here is a
manual modification of said script so that it exits after “checking for
a sed that does not truncate output”, which was sufficient to reproduce
the bug, possibly after many iterations).

It would be great to cut a Gash release soonish as this bug has been
blocking the ‘core-packages-team’ branch for a while already.

Thanks,
Ludo’.

#!/bin/sh
set -x
export COLUMNS=200
#STRACE="strace -s 100 -f -o log.strace"
PATCH=--with-patch=gash=$PWD/gash-redirect-EBADF.patch
export SHELL=$(guix build gash $PATCH)/bin/gash
export CONFIG_SHELL=$SHELL
OPTIONS="--prefix=/wherever --disable-bootstrap --disable-decimal-float --disable-libatomic --disable-libcilkrts --disable-libgomp --disable-libitm --disable-libmudflap --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libvtv --disable-lto --disable-lto-plugin --disable-multilib --disable-plugin --disable-threads --enable-languages=c,c++ --enable-static --enable-shared --enable-threads=single --disable-libstdcxx-pch --disable-build-with-cxx"

cd /data/src/gcc-4.9.4
while $STRACE $SHELL -e ./configure $OPTIONS $OPTIONS $OPTIONS
do
    grep fcntl.*EBADF log.strace && break
done