Fixes are available
XL C/C++ for AIX Fix Pack 13 (August 2015 Update) 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/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 21 (January 2019 Update) for 12.1
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
Document Information
Modified date:
19 August 2024