IBM Support

IV74072: BAD FILE DESCRIPTOR DUE TO OFSTREAM NOT RELEASING FILE AFTER ENOSPC

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • An invalid FILE descriptor is kept by an ofstream object after
    encountering an ENOSPC 'No space left on device' error.
    
    The issue occurs when the ofstream close() function is called
    when the file system being written to is full.  The system
    fclose() function is called, which in turn calls fflush() to
    write out any remaining data.  The fflush() fails with an ENOSPC
    error due to the full filesystem, and fclose() returns -1.  Even
    though -1 is returned, the fclose() function releases the FILE
    descriptor.
    
    Because -1 is returned from fclose(), the ofstream close() sets
    the ofstream failbit to 1, however is_open is still 1, and the
    FILE descriptor associated with the ofstream object is still
    treated as active.
    
    If the ofstream object is used again, it will be acting upon an
    inactive, invalid FILE descriptor, and undefined behaviour may
    be seen.
    

Local fix

Problem summary

  • PROBLEM DESCRIPTION:
    The C++ runtime incorrectly keeps the file descriptor alive
    after fclose() failed and the is_open flag remains true. This
    allows the second fclose() to close the file but the file
    descriptor has been freed by the first fclose() and reused by
    the system for another file.  As a result, the second fclose()
    closes a different stream.
    
    USERS AFFECTED:
    Users who close a file stream twice because the first attempt
    failed with an error such as no space left on device.
    

Problem conclusion

  • The C++ runtime behavior does not comply with the C++ standard
    and has now been fixed.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV74072

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2015-06-10

  • Closed date

    2015-07-28

  • Last modified date

    2015-07-28

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

    IV73852

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

Fix information

  • Fixed component name

    XL C/C++ RUNTIM

  • Fixed component ID

    5725C7201

Applicable component levels

  • RD10 PSY

       UP

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

Document Information

Modified date:
28 July 2015