G
Guest
I have come across a bug in FileStream.Close that causes File handles to leak.
If you create a FileStream then try to write to it when the destination disk
is full:
outputStream.Write(buffer, 0, readCount);
you get an IOException "There is not enough space on the disk".
That's fine, until you then try to dispose the FileStream, by calling
Dispose (or Close, which simply calls Dispose). Dispose attempts to flush
the stream, which causes it to attempt to write the buffer, which generates
an error (since the disk is full), which throws an IOException, leaving the
system file handle unreleased, resulting in a leaked handle.
I've considered obtaining the handle in my catch block and releasing it
directly, but that seems to be a path fraught with peril-- after all, I don't
know what else the FileStream code might do when the object is finalized...
Anyone else seen this? How do I go about reporting it to MS?
If you create a FileStream then try to write to it when the destination disk
is full:
outputStream.Write(buffer, 0, readCount);
you get an IOException "There is not enough space on the disk".
That's fine, until you then try to dispose the FileStream, by calling
Dispose (or Close, which simply calls Dispose). Dispose attempts to flush
the stream, which causes it to attempt to write the buffer, which generates
an error (since the disk is full), which throws an IOException, leaving the
system file handle unreleased, resulting in a leaked handle.
I've considered obtaining the handle in my catch block and releasing it
directly, but that seems to be a path fraught with peril-- after all, I don't
know what else the FileStream code might do when the object is finalized...
Anyone else seen this? How do I go about reporting it to MS?