[Bug 267527] bash crashes with segfault if LC_CTYPE or LC_ALL not set

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 02 Nov 2022 16:19:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267527

            Bug ID: 267527
           Summary: bash crashes with segfault if LC_CTYPE or LC_ALL not
                    set
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: ralph@lr.los-gatos.ca.us

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

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

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 forum, with some traces that _martin
collected, can be found in here:
https://forums.freebsd.org/threads/bash-is-broken-after-upgrade-to-5-2_3.86938/

-- 
You are receiving this mail because:
You are the assignee for the bug.