IBM Support

IJ24654: RUNTIME ABORT RELATED TO UNEXPECTED DESTRUCTOR CALL

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The executable produced from the following test case aborts at
    runtime.
    
    ===== COMPILE COMMAND:
    xlclang++ -O2 -qdebug=noopt  -qinlglue -qtune=balanced
    -qmaxmem=-1 -qstrict -brtl -qro -qarch=pwr4 -qcheck=divzero
    -qalias=noansi -qfuncsect=noimplicitstaticref -qcheck=nullptr
    -qchars=unsigned -std=c++11 -q64 problem.cpp -g
    
    
    ===== TESTCASE:
    $cat problem.cpp
    #include <string>
    #include <iostream>
    #include <cassert>
    
    class Never
    {
    public:
            Never()
            {
                    std::cerr << "Constructor called.\n";
            }
    
            ~Never()
            {
                    std::cerr << "Destructor called.\n";
            }
    };
    
    class Exception
    {
    public:
            // string may be any class, though not all are
    susceptible. It is easy enough
            // to replicate this behavior with a custom class. Just
    a simple class with one
            // void* m_begin, which does m_begin = ::operator new(1)
    and ::operator delete(m_begin)
            // in the destructor. That is sufficient.
            //
    
    
    
            Exception( std::string ) {}
    
    };
    
    class Test_class
    {
    public:
            void throwing_fun()
            {
    
                    // throw Exception("ju "); // illegal
    instruction in xlC
                    // throw Exception("Ju "); // segmentation
    violation in xlC
    
                    std::string throwthis = "Just a string long
    enough." ;
                    throw Exception(throwthis);
            }
    
            void error_fun()
            {
                    if (false)
                    {
                            Never* args = new Never;
                            try {
                                    std::cerr << "In try
    segment.\n";
                                    throwing_fun();
                                    return;
                            }
                            catch ( ... ) {
                                    std::cerr << "In catch
    segment.\n";
                                    delete args;
                                    assert(0);
                                    throw;
                            }
                    }
                    throwing_fun();
                    return  ;
            }
    
            // this function catches the exception, just so that
            // the program does not crash when things don't go
    wrong.
            void catching()
            {
                    try {
                            error_fun();
                    }
                    catch (...) {
    
                    }
            }
    
    };
    
    int main()
    {
            Test_class object;
            // for loop is necessary for the destructor te be
    called.
            // Otherwise, only the assert goes off.
            for (size_t i = 0; i < 1; i++)
            {
                    object.catching();
            }
            std::cout << "No problems found.\n";
    }
    $
    
    
    ===== ACTUAL OUTPUT:
    $ ./a.out
    In catch segment.
    Destructor called.
    Assertion failed: 0, file  problem.cpp, line 75
    Abort
    $
    
    ===== EXPECTED OUTPUT:
    $./a.out
    No problems found.
    $
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users who make use of inlining and exception handling may be
    affected by this issue.
    
    PROBLEM DESCRIPTION:
    When inlining functions contain a try block that contain early
    exits such
    as returns or goto's, the inliner can loose track of the current
    exception state
    causing a runtime abort.
    

Problem conclusion

  • The fix is to properly keep track of the current exception
    state.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IJ24654

  • 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-04-30

  • 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