Fixes are available
XL C/C++ for AIX Fix Pack 16 (November 2013 PTF) for 11.1
XL C/C++ for AIX Fix Pack 17 (February 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 18 (May 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 19 (August 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 20 (November 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 22 (September 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 24 (September 2016 PTF) for 11.1
APAR status
Closed as program error.
Error description
The below test case shows that throwing of exceptions causes destructors to be skipped, and creates all sorts of strange behavior down the chain with xlC V11.1 and V12.1. xlC v10.1 works. ===== TESTCASE: $cat test.cpp #include <iostream> class MyClassEmptyDestructor { bool v1; public: MyClassEmptyDestructor() : v1(false) { // Bug exposed whether constructor is empty or not /// std::cout << "MyClass constructor" << std::endl; } ~MyClassEmptyDestructor() { // Note: must be empty: if following is activated, all destructors are called ///std::cout << "MyClass destructor" << std::endl; } }; class Canary { unsigned int m_canary; public: // Note: a parameter is required here (doesn't need to be used). Canary(unsigned int id) : m_canary(id) { std::cout << "Canary entering " << m_canary << std::endl; } ~Canary() { // Sing - note singing is mandatory std::cout << "Canary exiting " << m_canary << std::endl; } }; void test_and_throw(bool exp) { // None of these destructors will be called Canary canary1(1); Canary canary2(2); Canary canary3(3); Canary canary4(4); if(exp) { // Must have class with empty destructor here // Even though execution path does not reach. MyClassEmptyDestructor myclass; return; // This return is also essential for the bug to show } // These destructors will be called Canary canary5(5); Canary canary6(6); throw "Naked Exception"; /// This throw is essential for the bug to show } int main(int argc, char **argv) { try { std::cout << "Calling test_and_throw" << std::endl; test_and_throw(false); std::cout << "After test_and_throw" << std::endl; } catch (...) { std::cout << "Caught exception" << std::endl; } } xlC_r test.cpp $./a.out Calling test_and_throw Canary entering 1 Canary entering 2 Canary entering 3 Canary entering 4 Canary entering 5 Canary entering 6 Canary exiting 6 Canary exiting 5 Caught exception Expected Output: xlC_r test.cpp $./a.out Calling test_and_throw Canary entering 1 Canary entering 2 Canary entering 3 Canary entering 4 Canary entering 5 Canary entering 6 Canary exiting 6 Canary exiting 5 Canary exiting 4 Canary exiting 3 Canary exiting 2 Canary exiting 1 Caught exception
Local fix
Do not make the destructor empty.
Problem summary
PROBLEM DESCRIPTION: Destructors were not being called due to error in state tables. USERS AFFECTED: All users constructing classes within or after a throw / exception handling
Problem conclusion
The issue has been solved. Apply applicable service.
Temporary fix
Comments
APAR Information
APAR number
IV46854
Reported component name
XL C/C++ AIX
Reported component ID
5724X1300
Reported release
B10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2013-08-09
Closed date
2013-11-18
Last modified date
2013-11-18
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++ AIX
Fixed component ID
5724X1300
Applicable component levels
RB10 PSY U863140
UP C
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
18 November 2013