bug-bash
[Top][All Lists]
Advanced

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

bash crashes with segfault if LC_CTYPE or LC_ALL not set


From: ralph
Subject: bash crashes with segfault if LC_CTYPE or LC_ALL not set
Date: Tue, 28 Nov 2023 08:16:05 -0800

Configuration Information [Manually overridden, the bug happened a while ago]:
Machine: i386 (32-bit), also occurs on amd64 (64 bit)
OS: freebsd12.3-RELEASE-p6
Compiler: cc
Compilation CFLAGS: unknown, from a pre-built FreeBSD package
uname output: FreeBSD house.lr.los-gatos.ca.us 12.3-RELEASE-p6 FreeBSD 
12.3-RELEASE-p6 GENERIC i386
Machine Type: i386 (exact same problem occurs on a separate amd64 machine, same 
OS version)

Bash Version: 5.2
Patch Level: 3
Release Status: release

Description:
        Applies to bash 5.2_3. Problem did not exist on 5.1_16. Problem
        observed on FreeBSD 12.3-RELEASE-p6, on both architectures i386 and
        amd64. Problem started after upgrading bash. Using packages, not built
        from ports.

        Bash crashes with a segfault, unless the variable LC_CTYPE or LC_ALL
        are set to a valid value (I have tried C, C.UTF-8, and en_US.UTF-8),
        before any "other" commands are executed. So it works if you start it
        as "LC_CTPYE=C /usr/local/bin/bash", or it works if you have
        "LC_CTPYE=C" as the first executed line of .bashrc (and exactly
        equivalent with LC_ALL). By "first executed line" I mean the first
        first non-comment line.

        If LC_CTYPE is set to a syntactically valid but non-existing locale
        (for example "C.XXX-8" instead of UTF), and that setting is not an
        environment variable set when bash starts, but happens in the first
        line of .bashrc, then bash first prints an error message (and then
        segfaults): bash: warning: setlocale: LC_CTYPE: cannot change locale
        (C.XXX-8): Invalid argument

        What's the impact of this? If a system has users who use bash as their
        login shell, they become locked out. And in a fashion that's hard to
        debug, since the only indication that is left is an error message in
        /var/log/auth.log.

        More discussion can be found in the FreeBSD forum, with some traces that
        user _martin collected, can be found in here:
        
https://forums.freebsd.org/threads/bash-is-broken-after-upgrade-to-5-2_3.86938/

Repeat-By:
        See above

Fix:
        Temporary workaround: Add LC_CTYPE=... (something valid) as the first
        line of .bashrc for all users.

        Problem no longer exists in bash 5.2-15 running on FreeBSD 13.2, but I
        don't know where it was fixed.



reply via email to

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