IBM Support

IJ15329: RUNTIME ABORT ON THROWN EXCEPTION WHEN USING -BRTL RUNTIME LINKING

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • An abort occurs at runtime after an exception is thrown in a
    shared library accessed via runtime linking.  The exception
    should have been caught in the library code, however the
    addition of the -brtl runtime linking option to the main
    executable causes different symbol binding to occur, and results
    in the abort.
    
    
       === TEST CASE ===
    
    // Shared Library Code
    #include <string>
    #include <stdexcept>
    void throwAndCatch() {
        try {
            std::string().substr(2);  // Triggers Exception
        } catch (const std::out_of_range &) { }
    }
    
    // Main Executable Code
    void throwAndCatch();
    
    int main() {
        throwAndCatch();
        return 0;
    }
    
       ===
    
    To Build:
    
    $ xlclang++ -qmkshrobj -o shared.so shared_library.cpp
    $ xlclang++ -Wl,-brtl main.cpp ./shared.so
    
    $ ./a.out
    IOT/Abort trap (core dumped)
    $
    
       ===
    
    Analysis of the corefile will show a reference to the
    __throw_out_of_range symbol in the cxa_demanlge component of
    libC.a:
    
    cxa_demangle.std::__1::__basic_string_common<true>::__throw_out_
    of_range() const() at 0xd243d66c
    
        (dbx) map 0xd334366c
        Entry 10:
           Object name: /usr/lib/libC.a
           Member name: shrcore.o
    
    This symbol binding is incorrect and should be bound to the
    symbol in libc++.a:
    
        Entry 3:
           Object name: /usr/lib/libc++.a
           Member name: shr.o
    

Local fix

  • Do not use runtime linking.
    

Problem summary

  • PROBLEM DESCRIPTION:
    A number of symbols, including __throw_out_of_range, were
    exported in the libC.a runtime library that should only be
    exported from the libc++.a runtime library.  The symbols are
    exported as weak symbols in libC.a, so normal linking works
    correctly, however runtime linking links with the incorrect
    symbols in libC.a, resulting in a runtime crash.
    
    USERS AFFECTED:
    Users compiling C++ code with the xlclang++ invocation, and
    using runtime linking (i.e. -Wl,-brtl).
    

Problem conclusion

  • The incorrectly exported symbols in libC.a were removed, and
    runtime linking will now work correctly.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IJ15329

  • 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

    2019-04-10

  • Closed date

    2019-07-25

  • Last modified date

    2019-07-25

  • 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"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"G10","Edition":"","Line of Business":{"code":"LOB73","label":"Power TPS"}}]

Document Information

Modified date:
21 August 2024