This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/65411] New: Unsafe(?) repeated call to fclose() in config/io/basic_file_stdio.cc


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]