libstdc++/2913

Brad Garcia garsh@home.com
Mon Nov 12 02:29:00 GMT 2001


  http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2913&database=gcc

We've done some testing and determined that the implementation
of basic_filebuf::_M_really_overflow is ignoring the return value of
_M_file->sync().  We are seeing sync() return EOF as expected during
the out-of-space condition, but since this isn't being checked and
propagated, the badbit is not getting set in basic_ios.

So this is definitely a bug in libstdc++, not in the operating system.
And it's a pretty severe bug.

Basically, we will never catch errors that occur when we attempt
to close a stream (where the close causes a final flush to occur
before actually closing the file).

pme said:

    The current default configuration passes I/O to the stdio
    fwrite(3) function; the only thing the C++ library knows
    is what fwrite(3) returns, namely, the bytes successfully
    written.  If something goes wrong (out of space), a short
    count is returned.  The C++ library tests for this
    condition (in xsputn()) and set the failbit accordingly.
    
    If the underlying filesystem doesn't do anything that would
    cause fwrite(3) to return an error, then the C++ library
    has nothing to go on.  The behavior of the OS kernel and
    its filesystem drivers also come into play.



Brad Garcia



More information about the Gcc-bugs mailing list