Skip to content

duplocale fails on AIX (locale.c: 2458: panic: duplocale failed; errno=22 Called by locale.c: 8734) #23825

@thoke

Description

@thoke

Description
Some time in the 5.39 development there were several locale related changes. This has led to duplocale failing on AIX.

I did a git bisect and here's the end result of my bisect...

22a00d7e56c86c42c8adc23415f09d82ef1e78f2 is the first bad commit
commit 22a00d7e56c86c42c8adc23415f09d82ef1e78f2
Author: Karl Williamson <[email protected]>
Date:   Sat Apr 1 12:08:37 2023 -0600

    locale.c: Extract code into a function

    This is in preparation for a future commit where it will be called from
    more than one place.

 embed.fnc |  34 +++++----
 embed.h   |  17 +++--
 locale.c  | 231 +++++++++++++++++++++++++++++++++++++-------------------------
 proto.h   |  29 ++++++--
 4 files changed, 191 insertions(+), 120 deletions(-)
bisect found first bad commit

My bisecting activity was doing a make miniperl and then running miniperl -v. In the case of the offending commit, it actually fails the make command...

"locale.c", line 6532.50: 1506-045 (S) Undeclared identifier language.
make: The error code from the last command is 1.


Stop.

Here's that referenced line of code:

6532                 output_check_environment_warning(language, lc_all, lang);

I was able to move a couple of commits ahead to:

commit f0578dea2221b23824ec44cb18f024cffc2f9069 (HEAD)
Author: Karl Williamson <[email protected]>
Date:   Thu Mar 30 21:05:35 2023 -0600

    locale.c: Rework locale initialization loop

    The previous code was always hard to understand, with a self-modifying
    loop.  I finally figured out a clearer way to do it, by using an enum
    with all the possibilities, and a switch statement that sets up the loop
    for each, or decides this possibility isn't valid on this platform.  The
    first possibility that works exits the loop.

M       locale.c

And things compiled again and also got the panic:

+ LC_ALL=en_US
+ ./miniperl -v
locale.c: 2040: panic: duplocale failed; errno=22
Called by locale.c: 6101

+ exit 1

Steps to Reproduce
Basically, build perl and then run perl -v with the locale set to something other than C. It even happens when building/running miniperl.

$ LANG=en_US /extsrc/perl/5.42.0a/rs6000_71/bin/perl -v
locale.c: 2458: panic: duplocale failed; errno=22
Called by locale.c: 8734

Expected behavior
Perl should not panic.

$ LANG=en_US /extsrc/perl/5.42.0a/rs6000_71/bin/perl -v || LANG=C /extsrc/perl/5.42.0a/rs6000_71/bin/perl -v
locale.c: 2458: panic: duplocale failed; errno=22
Called by locale.c: 8734


This is perl 5, version 42, subversion 0 (v5.42.0) built for aix-thread-multi-64all

Copyright 1987-2025, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.

Perl configuration

Summary of my perl5 (revision 5 version 42 subversion 0) configuration:

  Platform:
    osname=aix
    osvers=7.1.0.0
    archname=aix-thread-multi-64all
    uname='aix 1 7 powerpc'
    config_args='-A ccflags=-q64 -Dcc=/opt/IBM/xlC/16.1.0/bin/xlc -Dusethreads -des -Dprefix=/extsrc/perl/5.42.0a/rs6000_71 -Dcf_by=Cohesity [email protected] -Dmydomain=cohesity.com -Dmyhostname=buildhost [email protected] -Dmyuname=aix 1 7 powerpc'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='/opt/IBM/xlC/16.1.0/bin/xlc -q64'
    ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=-1 -qnoansialias -qlanglvl=extc99 -DUSE_NATIVE_DLOPEN -q64 -DNEED_PTHREAD_INIT -q64 -DUSE_64_BIT_ALL -q64'
    optimize='-O'
    cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=-1 -qnoansialias -qlanglvl=extc99 -DUSE_NATIVE_DLOPEN -q64 -DNEED_PTHREAD_INIT'
    ccversion=''
    gccversion=''
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=87654321
    doublekind=4
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='ld'
    ldflags ='-brtl -bdynamic -L/usr/local/lib -b64'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lpthread -lbind -ldbm -ldl -lld -lm -lcrypt -lpthreads -lc
    perllibs=-lpthread -lbind -ldl -lld -lm -lcrypt -lpthreads -lc
    libc=
    so=a
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_aix.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='  -bE:/extsrc/perl/5.42.0a/rs6000_71/lib/5.42.0/aix-thread-multi-64all/CORE/perl.exp'
    cccdlflags=' '
    lddlflags='-b64 -bhalt:4 -G -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -bnoentry -lpthreads -lc -lm -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under aix
  Compiled at Sep 16 2025 06:12:36
  @INC:
    /extsrc/perl/5.42.0a/rs6000_71/lib/site_perl/5.42.0/aix-thread-multi-64all
    /extsrc/perl/5.42.0a/rs6000_71/lib/site_perl/5.42.0
    /extsrc/perl/5.42.0a/rs6000_71/lib/5.42.0/aix-thread-multi-64all
    /extsrc/perl/5.42.0a/rs6000_71/lib/5.42.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions