• Bug#1108971: bash: computes wrong PIPESIZE during some cross builds

    From Helmut Grohne@21:1/5 to All on Tue Jul 8 21:00:01 2025
    Source: bash
    Version: 5.2.37-2
    Tags: patch upstream
    User: [email protected]
    Usertags: rebootstrap
    X-Debbugs-Cc: [email protected], [email protected]

    bash has a weired way to compute PIPESIZE. It's a property of the
    kernel, but it is not being checked for during ./configure. Instead the builtins/Makefile.in compiles a builtins/psize.c (using CC_FOR_BUILD)
    and runs a builtins/psize.sh to create a pipesize.h #defining PIPESIZE.
    It even has a comment noting that this gets the value for the build architecture while it should be getting it from the host.

    Turns out if you cross build bash for hurd on linux you get the wrong
    value in such a way that it practically doesn't work. It would be good
    if we could preseed this value rather than having it use something bad.

    I argue that it really should be a configure time check with a proper
    autoconf cache variable allowing overriding and that's exactly what the attached patch does. What do you think about it?

    Of course this is not trixie material.

    Helmut and Samuel

    --- bash-5.2.37.orig/aclocal.m4
    +++ bash-5.2.37/aclocal.m4
    @@ -2265,3 +2265,87 @@
    fi
    AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
    ])
    +AC_DEFUN(BASH_PIPESIZE,
    +[AC_CACHE_CHECK([for PIPESIZE], bash_cv_pipesize, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[
    +/* Write output in 128-byte chunks until we get a sigpipe or write gets an
    + EPIPE. Then report how many bytes we wrote. We assume that this is the
    + pipe size. */
    +#if defined (HAVE_UNISTD_H)
    +# ifndef _MINIX
    +# include <unistd.h>
    +# endif
    +#endif
    +
    +#include <stdio.h>
    +#include <sys/types.h>
    +#if HAVE_STDINT_H
    +# include <stdint.h>
    +#endif
    +#include <signal.h>
    +#ifdef HAVE_STDLIB_H
    +#include <stdlib.h>
    +#endif
    +
    +FILE *output;
    +int nw;
    +
    +void sigpipe (int sig)
    +{
    + fprintf (output, "%d\n", nw);
    + fclose (output);
    + exit (0);
    +}
    +
    +int main (int argc, char **argv)
    +{
    + char buf[128];
    + int pipes[2];
    + int pid