IBM Support

IV73852: 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 ofstream object 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 ofstream object behavior does not comply with the C++
    standard and has now been fixed.
    
    This APAR (IV73852) denotes the fix to the <fstream> header
    file, which corrects the problem in applications that use
    ofstream directly in their code.  APAR IV78285 denotes a
    re-build of the XL C++ Runtime to use the fixed <fstream> header
    file, to ensure all usage of ofstream within the XL C++ Runtime
    itself is corrected.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV73852

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-06-03

  • Closed date

    2015-10-23

  • Last modified date

    2015-10-23

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

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

    IV74072 IV74663

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"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"12.1","Edition":"","Line of Business":{"code":"LOB73","label":"Power TPS"}}]

Document Information

Modified date:
19 August 2024