[Bug libstdc++/65411] New: Unsafe(?) repeated call to fclose() in config/io/basic_file_stdio.cc
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 12 20:00:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65411
Bug ID: 65411
Summary: Unsafe(?) repeated call to fclose() in
config/io/basic_file_stdio.cc
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html says:
Whether or not the call succeeds, the stream shall be disassociated from
the file [...] The fclose() function shall perform the equivalent of a
close() on the file descriptor that is associated with the stream pointed
to by stream. [...] After the call to fclose(), any use of stream results
in undefined behavior.
We do this in __basic_file<char>::close()
errno = 0;
do
__err = fclose(_M_cfile);
while (__err && errno == EINTR);
We should check whether that's correct.
http://austingroupbugs.net/view.php?id=529 tells me that close() on linux (and
everywhere except HPUX) always closes the fd even if interrupted.
More information about the Gcc-bugs
mailing list