Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 21, 2004 [Heisenbug] std.stream.File opening fails in certain circumstances for apparently no reason at all | ||||
---|---|---|---|---|
| ||||
Using DMD 0.101, Windows 98SE. This code is part of an attempt to add message logging to my SDWF, inserted into the WindowBase class in, unsurprisingly, windowbase.d. It is totally driving me mad to figure why it won't work. Having built the lib with -debug=messageLog throughout, and then built an SDWF app (such as skel), it just refuses to open the output file. It gets as far as giving me the messages "Opened log file", "Not open" and then the fatal exception "unable to write to stream". There are two things wrong here. Firstly that the file fails to open, and secondly that the File constructor isn't telling me this via an exception. ---------- debug (messageLog) { static { File messageLogFile; } static this() { messageLogFile = new File("messages.log", FileMode.Out); MessageBoxA(null, "Opened log file", "Debug", MB_OK); MessageBoxA(null, messageLogFile.isOpen ? "Not open" : "Open", "Debug", MB_OK); messageLogFile.writeLine("Opened log file"); MessageBoxA(null, "Written to log file", "Debug", MB_OK); } } ---------- The same bug occurs if I use FileMode.OutNew, or use File.create or File.open instead of opening it in the constructor. And it doesn't seem to matter whether I link with sdwf.lib, link all the .obj files together or compile the .d files in one go. Or take away the embracing as debug code. I cannot for the life of me determine what's peculiar here. All attempts to reduce the problem to a small, self-contained program have proven fruitless. Does anyone have the slightest idea what can cause this failure? It's definitely nothing to do with a full or write-protected disk, or anything like that! Stewart. |
September 21, 2004 Re: [Heisenbug] std.stream.File opening fails in certain circumstances for apparently no reason at all | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | "Stewart Gordon" <Stewart_member@pathlink.com> wrote in message news:cipb56$14ne$1@digitaldaemon.com... > Using DMD 0.101, Windows 98SE. > > This code is part of an attempt to add message logging to my SDWF, inserted into > the WindowBase > class in, unsurprisingly, windowbase.d. It is totally driving me mad to figure > why it won't work. > > Having built the lib with -debug=messageLog throughout, and then built an SDWF > app (such as skel), it > just refuses to open the output file. It gets as far as giving me the messages > "Opened log file", "Not > open" and then the fatal exception "unable to write to stream". > > There are two things wrong here. Firstly that the file fails to open, and > secondly that the File > constructor isn't telling me this via an exception. > > ---------- > debug (messageLog) { > static { > File messageLogFile; > } > > static this() { > messageLogFile = new File("messages.log", FileMode.Out); > MessageBoxA(null, "Opened log file", "Debug", MB_OK); > > MessageBoxA(null, messageLogFile.isOpen ? "Not open" : "Open", > "Debug", MB_OK); > > messageLogFile.writeLine("Opened log file"); > MessageBoxA(null, "Written to log file", "Debug", MB_OK); > } > } > ---------- > > The same bug occurs if I use FileMode.OutNew, or use File.create or File.open > instead of opening it in > the constructor. And it doesn't seem to matter whether I link with sdwf.lib, > link all the .obj files > together or compile the .d files in one go. Or take away the embracing as debug > code. > > I cannot for the life of me determine what's peculiar here. All attempts to > reduce the problem to a > small, self-contained program have proven fruitless. > > Does anyone have the slightest idea what can cause this failure? It's > definitely nothing to do with a full > or write-protected disk, or anything like that! > > Stewart. > Very wierd. When I use the phobos.lib that is in the zip file for dmd-101 then it does all kinds of strange things like giving an Access Violation when I try to close or it creates empty files or it errors with "Invalid UTF-8 sequence" or "File '' not found". When I recompile phobos it works fine. Can you try recompiling phobos? -Ben |
September 22, 2004 Re: [Heisenbug] std.stream.File opening fails in certain circumstances for apparently no reason at all | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | In article <cipens$17ki$1@digitaldaemon.com>, Ben Hinkle says... <snip> >> It gets as far as giving me the messages "Opened log file", "Not open" and then the fatal exception "unable to write to stream". Oops, I don't know how I managed to get my sense of "open" vs. "not open" mixed up. The file _is_ opening, and further debugging messages indicate that messageLogFile.writeable == true && messageLogFile.readable == false as expected. It's not until I try to actually do some writing that something goes wrong. <snip> > Very wierd. When I use the phobos.lib that is in the zip file for dmd-101 then it does all kinds of strange things like giving an Access Violation when I try to close or it creates empty files or it errors with "Invalid UTF-8 sequence" or "File '' not found". When I recompile phobos it works fine. Can you try recompiling phobos? It seems that recompiling Phobos does sometimes work wonders, but sadly for me it hasn't worked this one. But then again, SDWF has progressed a bit on my box. (As has Phobos for that matter.) But not in ways that should've broken code that doesn't depend on it. But I'll try again with DMD 0.102.... Stewart. |
September 23, 2004 Re: [Heisenbug] std.stream.File opening fails in certain circumstances for apparently no reason at all | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | In article <cirj0p$28dd$1@digitaldaemon.com>, Stewart Gordon says... <snip> >But I'll try again with DMD 0.102.... Done, and the problem has disappeared. Time to get back to fixing the bugs that I can now finally diagnose.... Stewart. |
Copyright © 1999-2021 by the D Language Foundation