[Issue 6880] Heisenbug: deferred crash when writing to stdout on Windows without console.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 27 11:10:27 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=6880

--- Comment #8 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
As I understand, what happens here is:

1. The program starts, and writes data to stdout / stderr
2. The data goes into the C FILE* buffer
3. When the buffer fills up, the C runtime attempts to flush it
4. Upon flushing, it discovers that the output handle in non-writable

Perhaps the runtime could detect an unwritable stdout/stderr and close (or
otherwise make invalid) the respective std.stdio handles.

Though, even if writeln was changed to check if the output handle is writable
on first or every write, the steps to reproduce would still apply - a forgotten
writeln inside some rarely-executed code, such as an error handler, can still
go through initial testing and end up crashing the application on the
end-user's site.

--


More information about the Digitalmars-d-bugs mailing list