Skip to content

Conversation

@khwilliamson
Copy link
Contributor

This test gets variously an illegal instruction or segfault from within setlocale(). The default shell and bash on this system forbid the changing of LC_ALL to an illegal value, so the setlocale(3) command is insulated from getting this kind of input in actual operation.

This test was written in such a way as to get around such shell restrictions, and it turns out that the z/OS setlocale can't cope. I haven't written a ticket to IBM because this really can't happen without a sneaky test that involves perl or something else very unlikely to happen in real life.

There is no good single-stepping debugger available I was told by an IBM person, so I tried narrowing the cause down by adding debug statements. I had to flush the buffer each time, and the results were more like going down a rabbit hole.

It turns out that when a test on the box I tested this with crashes, a human readable dump is output. It showed that the failure is within an internal function 'locale_init()' called from setlocale(3). That is a pretty strong indication that setlocale(3) isn't validating its input, and it isn't perl's fault.

  • This set of changes does not require a perldelta entry.

This test gets variously an illegal instruction or segfault from within
setlocale().  The default shell and bash on this system forbid the
changing of LC_ALL to an illegal value, so the setlocale(3) command is
insulated from getting this kind of input in actual operation.

This test was written in such a way as to get around such shell
restrictions, and it turns out that the z/OS setlocale can't cope.  I
haven't written a ticket to IBM because this really can't happen without
a sneaky test that involves perl or something else very unlikely to
happen in real life.

There is no good single-stepping debugger available I was told by an IBM
person, so I tried narrowing the cause down by adding debug statements.
I had to flush the buffer each time, and the results were more like
going down a rabbit hole.

It turns out that when a test on the box I tested this with crashes, a
human readable dump is output.  It showed that the failure is within
an internal function 'locale_init()' called from setlocale(3).  That is
a pretty strong indication that setlocale(3) isn't validating its input,
and it isn't perl's fault.

This is a typical dump of the problem.  (Note, the perl is compiled
without threads.)  S_posix_setlocale_with_complications() is the lowest
perl function called.

CEE3DMP V3 R1.0: Condition processing resulted in the unhandled condition.         Mon Jun  2 19:26:40 2025             Page:    1
ASID: 004B   PID: 67175275   Parent PID: 33619980   User name: DEVUSER

CEE3845I CEEDUMP Processing started.

Information for enclave main

  Information for thread 1B12A80000000000

  Traceback:
    DSA   Entry       E  Offset  Statement   Load Mod             Program Unit                   Service  Status
    1     CEEHDSP     +00003FD8              CELQLIB              CEEHDSP                        HLE77E0  Call
    2     CEEOSIGJ    +0000095C              CELQLIB              CEEOSIGJ                       HLE77E0  Call
    3     CELQHROD    +00000266              CELQLIB              CELQHROD                       HLE77E0  Call
    4     CEEOSIGG    -13FB9470              CELQLIB              CEEOSIGG                       HLE77E0  Call
    5     CELQHROD    +00000266              CELQLIB              CELQHROD                       HLE77E0  Call
    6     locale_init -1C0CE168              CELQLIB                                             HLE77E0  Exception
    7     set_locale  +00001C86              CELQLIB                                             UI95787  Call
    8     setlocale   +00000020              CELQLIB                                             UI95787  Call
    9     S_posix_setlocale_with_complications
                      +00000CF2              perl                                                         Call
    10    Perl_setlocale
                      +0000055E              perl                                                         Call
    11    XS_POSIX_setlocale
                      +000002B4              perl                                                         Call
    12    Perl_rpp_invoke_xs
                      +000001AC              perl                                                         Call
    13    Perl_pp_entersub
                      +000050AE              perl                                                         Call
    14    Perl_runops_debug
                      +000005E8              perl                                                         Call
    15    S_run_body  +00000A48              perl                                                         Call
    16    perl_run    +00000424              perl                                                         Call
    17    main        +00000244              perl                                                         Call
    18    CELQINIT    +00001ACA              CELQLIB              CELQINIT                       HLE77E0  Call

    DSA   DSA Addr          E  Addr             PU Addr           PU Offset   Comp Date Compile Attributes
    1     00000050082F8600  000000001BFFADD0    000000001BFFADD0  00003FD8    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP
    2     00000050082FB760  000000001C2B53C0    000000001C2B53C0  0000095C    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP
    3     00000050082FC160  000000001C00E7E0    000000001C00E7E0  00000266    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP
    4     00000050082FC360  000000001C2AE3B0    000000001C2AE3B0  13FB9470    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP
    5     00000050082FD380  000000001C00E7E0    000000001C00E7E0  00000266    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP
    6     00000050082FD580  000000001C0CE168    0000000000000000  ********    20230307  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    7     00000050082FD680  000000001C2FA220    0000000000000000  ********    20240223  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    8     00000050082FD980  000000001C2FC2C8    0000000000000000  ********    20240223  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    9     00000050082FDA80  000000001B0144F0    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    10    00000050082FDD40  000000001B0163B0    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    11    00000050082FDF60  000000001AA60058    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    12    00000050082FE0E0  000000001B475770    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    13    00000050082FE1C0  000000001B46DE30    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    14    00000050082FE940  000000001B17B2C0    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    15    00000050082FEA20  000000001A7EE310    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    16    00000050082FEB40  000000001A7ED370    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    17    00000050082FF100  000000001A70D940    0000000000000000  ********    20250603  C/C++     POSIX  XPLINK  EBCDIC  IEEE
    18    00000050082FF200  000000001BDE5010    000000001BDE5010  00001ACA    20230307  CEL       POSIX  XPLINK  EBCDIC  HFP

    Fully Qualified Names
    DSA   Entry       Program Unit                                        Load Module
    9     S_posix_setlocale_with_complications
                                                                          ./perl
CEE3DMP V3 R1.0: Condition processing resulted in the unhandled condition.         Mon Jun  2 19:26:40 2025             Page:    2
ASID: 004B   PID: 67175275   Parent PID: 33619980   User name: DEVUSER

    10    Perl_setlocale
                                                                          ./perl
    11    XS_POSIX_setlocale
                                                                          ./perl
    12    Perl_rpp_invoke_xs
                                                                          ./perl
    13    Perl_pp_entersub
                                                                          ./perl
    14    Perl_runops_debug
                                                                          ./perl
    15    S_run_body                                                      ./perl
    16    perl_run                                                        ./perl
    17    main                                                            ./perl

    Full Service Level
    DSA   Entry       Service
    6     locale_init HLE77E0:EDCNLSET
    7     set_locale  UI95787:CELHSTLC
    8     setlocale   UI95787:CELHSTLC

  Condition Information for Active Routines
    Condition Information for  (DSA address 00000050082FD580)
      CIB Address: 00000050082F9948
      Current Condition:
        CEE0198S The termination of a thread was signaled due to an unhandled condition.
      Original Condition:
        CEE3201S The system detected an operation exception (System Completion Code=0C1).
      Location:
        Program Unit:  Entry: locale_init
        Statement:     Offset: -1C0CE168
      Machine State:
        ILC..... 0002    Interruption Code..... 0001
        PSW..... 0785240180000000 0000000000000002
        GPR0..... 000000001C7C5238  GPR1..... 0000005008CB0210  GPR2..... 0000005009A1CCA0  GPR3..... 0000005009A1D908
        GPR4..... 00000050082FD580  GPR5..... 0000000000000000  GPR6..... 0000000000000000  GPR7..... 000000001C0CE1B8
        GPR8..... 0000005008CB0210  GPR9..... 0000000000000004  GPR10.... 0000005009A1D908  GPR11.... 0000000000000001
        GPR12.... 0000005000108398  GPR13.... 0000000000000000  GPR14.... 0000000000000000  GPR15.... 00000000000001E8
        FPC...... 00080000
        FPR0..... 00000000  00000000            FPR1..... 43F00000  00000000
        FPR2..... 00000000  00000000            FPR3..... 413243F6  A8885A31
        FPR4..... 40030000  00000000            FPR5..... 416487ED  5110B461
        FPR6..... 00000000  00000000            FPR7..... 411921FB  54442D18
        FPR8..... 00000000  00000000            FPR9..... 00000000  00000000
        FPR10.... 00000000  00000000            FPR11.... 00000000  00000000
        FPR12.... 00000000  00000000            FPR13.... 00000000  00000000
        FPR14.... 00000000  00000000            FPR15.... 00000000  00000000

    Storage dump near condition, beginning at location(0000000000000000)
      +0000 0000000000000000  Inaccessible storage.
      +0010 0000000000000010  Inaccessible storage.
    GPREG STORAGE:
      Storage around GPR0 (000000001C7C5238)
        -0020 000000001C7C5218  00C300C5 00C500F1 00000248 00000108  |.C.E.E.1........|
        -0010 000000001C7C5228  B9040015 E3301288 017147F0 70020000  |....T..h...0....|
        +0000 000000001C7C5238  C9C2D460 F0F3F700 819395A4 94000000  |IBM-037.alnum...|
        +0010 000000001C7C5248  81939788 81000000 82938195 92000000  |alpha...blank...|
        +0020 000000001C7C5258  8395A399 93000000 84898789 A3000000  |cntrl...digit...|
CEE3846I CEEDUMP Processing completed.

The dump went on for nearly 3K more lines, that are basically repeats
@khwilliamson khwilliamson merged commit b84dc2d into Perl:blead Nov 2, 2025
34 checks passed
@khwilliamson khwilliamson deleted the os390_illegal_locale_names branch November 2, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants