IV45505: TRY-CATCH BLOCK CHANGES VALUE OF ERRNO

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

  • RC10 PSY U860115

       UP C



Rate this page:

(0 users)Average rating

Document information


More support for:

XL C/C++ for AIX
C/C++ Runtime

Software version:

12.1

Reference #:

IV45505

Modified date:

2013-09-20

Translate my page

Machine Translation

Content navigation