IBM Support

IJ23820: STORE TO NULL WHEN INITIALIZING GLOBAL THREAD_LOCAL ARRAY

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When initializing a thread_local array, a store to NULL occurs
    causing a segmentation fault.  The stacktrace shows the code
    going through the "TLS init function" and "TLS wrapper
    function", until it tries to create a Class
    __compressed_pair_elem - the bad store happens in the
    constructor for this class:
    
       std::__1::__compressed_pair_elem<std::__1::basic_string<char,
       std::__1::char_traits<char>, std::__1::allocator<char>
       >::__rep,0, false>::__compressed_pair_elem()(this = (nil)),
       line 2043 in "memory"
       _ZTH3str() at 0x100000da8          ==> TLS init function
       _ZTW3str(), line 2062 in "memory"  ==> TLS wrapper function
       main(), line 9 in "main.cpp"
    
    
       === TEST CASE ===
    
    #include <iostream>
    #include <string>
    using namespace std;
    
    thread_local string str[5];
    
    int main()
    {
       str[1] = "ThreadLocal";
       cout << "String: " << str[1] << endl;
    }
    
    
    
    $ xlclang++ main.cpp
    $ ./a.out
    Segmentation fault (core dumped)
    $
    

Local fix

Problem summary

  • USERS AFFECTED:
    Users of non-local arrays with thread_local storage duration
    that have or might have
    non-constant initialization maybe affected by this issue.
    Users of similar thread_local references to functions may also
    be affected by this issue.
    
    PROBLEM DESCRIPTION:
    The thread-local wrapper function that is meant to cause
    initialization of a
    thread-local array with non-local possibly-non-constant
    initialization
    on its first use may be incorrectly generated and/or
    incorrectly called.
    This may manifest as a compile-time abend, a runtime abend, or
    incorrect output at runtime.
    

Problem conclusion

  • The generation of thread-local wrapper functions is corrected
    to
    avoid issues related to array-to-pointer conversion,
    function-to-pointer conversion, etc.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IJ23820

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    G10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2020-03-27

  • Closed date

    2020-04-30

  • Last modified date

    2020-04-30

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ FOR AI

  • Fixed component ID

    5725C7200

Applicable component levels

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Line of Business":{"code":"LOB73","label":"Power TPS"}}]

Document Information

Modified date:
22 August 2024