IBM Support

IV45505: TRY-CATCH BLOCK CHANGES VALUE OF ERRNO

Fixes are available

XL C/C++ for AIX Fix Pack 18 (July 2013 PTF) for 10.1
IBM XL C++ Runtime for AIX Fix Pack 2 (July 2013 PTF) for 12.1
XL C/C++ for AIX Fix Pack 15 (August 2013 PTF) for 11.1
XL C/C++ for AIX Fix Pack 5 (September 2013 PTF) for 12.1
XL C++ Runtime for AIX Fix Pack 3 (September 2013 PTF) for 12.1
XL C/C++ for AIX Fix Pack 19 (October 2013 PTF) for 10.1
XL C/C++ for AIX Fix Pack 16 (November 2013 PTF) for 11.1
XL C/C++ for AIX Fix Pack 7 (January 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 17 (February 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 8 (March 2014 PTF) for 12.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 11 (February 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 12 (May 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 13 (August 2015 Update) for 12.1
XL C++ Runtime for AIX Fix Pack 4 (August 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 22 (September 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 21 (October 2015 PTF) for 10.1
XL C++ Runtime for AIX Fix Pack 5 (October 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 14 (December 2015 Update) for 12.1
XL C/C++ for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 15 (April 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 16 (July 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 24 (September 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 17 (November 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 18 (February 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 19 (August 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 20 (March 2018 Update) for 12.1
XL C/C++ for AIX Fix Pack 6 (December 2013 PTF) for 12.1
XL C/C++ for AIX Fix Pack 9 (July 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 20 (October 2014 PTF) for 10.1
XL C/C++ for AIX Fix Pack 10 (October 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 21 (January 2019 Update) for 12.1

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Consider the following test case:
    
    
    $cat errno_catch_test.cpp
    /********************************************/
    #include <cerrno>
    #include <iostream>
    
    void setErrno() {
    errno = 123;
    throw 456;
    }
    
    void testErrno() {
    try {
    setErrno();
    }
    catch (int i) {
    if (123 == errno) {
    std::cout << "Worked" << std::endl;
    } else {
    std::cout << "Failed" << std::endl;
    }
    std::cout << "Caught " << i << std::endl;
    return;
    }
    std::cout << "Throw not caught.";
    }
    
    int main() {
    testErrno();
    }
    /********************************************/
    
    Compile as:
    
    xlC_r -q64 -o errno_catch_test errno_catch_test.cpp
    
    Execute the binary as:
    
    ./errno_catch_test
    
    
    The output is:
    
    
    Failed
    Caught 456
    
    
    The expected output should be:
    
    Worked
    Caught 456
    

Local fix

  • Save the errno value before the control enters a try-catch
    block.
    

Problem summary

  • USERS AFFECTED: Users who check the value of errno set earlier
    after the control goes through a try-catch block are affected
    by this issue.
    
    PROBLEM DESCRIPTION:
    The value in errno gets changed after the control goes through
    a try-catch block.
    

Problem conclusion

  • System call loadbind() which is executed in the implementation
    of try-catch block sets errno in 64-bit mode.  As a result, the
    original value is overwritten.
    The compiler has been fixed to save and restore errno around
    the call to loadbind().
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV45505

  • Reported component name

    XL C/C++ AIX

  • Reported component ID

    5724X1300

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-07-11

  • Closed date

    2013-07-17

  • Last modified date

    2013-09-20

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

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

    LI77673

Fix information

  • Fixed component name

    XL C/C++ RUNTIM

  • Fixed component ID

    5725C7201

Applicable component levels

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSC6KWG","label":"C\/C++ Runtime"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"12.1","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
20 September 2013