Problem with writeln

Ivan ivan.senji at gmail.com
Mon Mar 1 01:11:28 PST 2010


On 28.2.2010 20:42, Walter Bright wrote:
> Since printf and writeln versions both exhibit the same problem, I
> suspect the problem is elsewhere in your program.

That wouldn't surprise me :)

But I am having some problems figuring this out. Somehow playing with 
ddbg i was able to get this stack trace:

#0 ?? () at C:\dmd2\windows\bin\..\..\src\phobos\std\contracts.d:147 
from KERNEL32.dll
#1 0x00411724 in __d_throw at 4 () at 
C:\dmd2\windows\bin\..\..\src\phobos\std\contracts.d:147 from deh
#2 0x004049f8 in 
_D3std5stdio4File17LockingTextWriter12__T3putTAxaZ3putMFAxaZv () at 
C:\dmd2\windows\bin\..\..\src\phobos\std\contracts.d:147
#3 0x00404887 in 
_D3std6format65__T19writeUpToFormatSpecTS3std5stdio4File17LockingTextWriterTAxaZ19writeUpToFormatSpecFKS3std5stdio4File17LockingTextWriterKAxaZv 
() at C:\dmd2\windows\bin\..\..\src\phobos\std\format.d:1724
#4 0x004062cc in 
_D3std6format62__T14formattedWriteTS3std5stdio4File17LockingTextWriterTaTAyaZ14formattedWriteFKS3std5stdio4File17LockingTextWriterAxaAyaZv 
(w = 0x0013fdb8, fmt = "Exception was: %s", _param_2 = "unable to write 
to stream") at C:\dmd2\windows\bin\..\..\src\phobos\std\format.d:2189
#5 0x00406225 in 
_D3std5stdio4File21__T8writeflnTAyaTAyaZ8writeflnMFAyaAyaZv () at 
C:\dmd2\windows\bin\..\..\src\phobos\std\stdio.d:581
#6 0x004061a9 in _D3std5stdio21__T8writeflnTAyaTAyaZ8writeflnFAyaAyaZv 
(_param_0 = "Exception was: %s", _param_1 = "unable to write to stream") 
at C:\dmd2\windows\bin\..\..\src\phobos\std\stdio.d:1310
#7 0x004033ea in _Dmain (args = {
   [0] = "D:\\ivans\\Projects\\D\\eclipse-workspace-d\\ifs3d\\ifs3d.exe"
}) at ivan\ifs3d\ifs3d.d:98
#8 0x00411534 in extern (C) int rt.dmain2.main(int, char**) . void 
runMain(void*) () from dmain2
#9 0x00411571 in extern (C) int rt.dmain2.main(int, char**) . void 
runAll(void*) () from dmain2
#10 0x004112e4 in _main () from dmain2
#11 0x00473c41 in _mainCRTStartup () from constart
#12 0x7c817077 in ?? () from KERNEL32.dll

The part of code in my main method is this:

	try {
		writefln("Starting main loop...");
		global.loop.start();
		writefln("Main loop finished...");
	} catch(Exception e) {
		writefln("Exception was: %s", e.msg);
	}

 From what I can see an exception was thrown ("unable to write to 
stream") and the only line I added to the loop is this:

	writefln(". %s", counter++);

If that line is removed, an exception seams to be thrown from the line
	writefln("Main loop finished...");

And this is the exception:

Unhandled D Exception (std.contracts.ErrnoException
  "C:\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(896):  (No error)") 
at KERNEL32.dll (0x7c812afb) thread(3548)

Has anyone ever had an exception like this? Any tips on debugging?



More information about the Digitalmars-d mailing list