November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6880

           Summary: Heisenbug: deferred crash when writing to stdout on
                    Windows without console.
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: verylonglogin.reg@gmail.com


--- Comment #0 from Denis <verylonglogin.reg@gmail.com> 2011-11-02 16:42:48 MSK ---
A possible Release-only bug: deferred crash when writing to stdout on Windows without console.

To reproduce:
1. Write a program using `writeln` for debugging output.
2. Prefix every `writeln` with a `debug` except one which was missed.
3. Create a release build with SUBSYSTEM:WINDOWS which has no console and test
it a bit to see it launches and works.
4. Take tons of user feedbacks like: "It works about a minute (10 minues, an
hour) and than it crashes."

Fitst two Steps will be solved as soon as
Suggestion #1. some debug tracing will be added to Phobos (std.log, e.g.) and
Suggestion #2. `writeln` with friends will be marked by a big red text "NOT FOR
DEBUG OUTPUT, USE ... INSTEAD".

But it still can be a situation like when you need an optional non-debug console output for some reason, e.g. program can optionally work in a console mode and than you have missed one `if(consoleMode)` prefix.

Suggestion #3. Throw an exception as soon as `writeln` is called and standard
output stream is invalid, like .NET Framework's
System.IO.Console.WriteLine()...
Strange, but I can't reproduce such exception in .NET Framework any more, now
WriteLine() just silently doing nothing, maybe I mixed something in memory, it
was a long time ago... Anyway, this silence looks not good.

And
Suggestion #4. Remove writing debug info to a console in release from Phobos
(e.g. std.typecons.Unique) and disallow such code in Phobos forever.


But all this is just IMO, what do you think?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6880


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com


--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-11-02 14:40:04 PDT ---
It would help if you provided a stack trace. You can write a WinMain which displays uncaught exceptions in a message box: http://www.digitalmars.com/d/2.0/windows.html

You may find this helpful:

if (!GetConsoleWindow()) {
    stdout.open("stdout.log", "w");
    stderr.open("stderr.log", "w");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------