object.Exception at std/stdio.d(1321): Enforcement failed - I must be doing something wrong?
Colin Grogan
grogan.colin at gmail.com
Thu Aug 15 10:03:32 PDT 2013
Hi all,
I've done this a million times (I thought!) but I'm getting a
strange error I cant figure out.
The code:
void writeMsg(string msg){
logFile.writeln(msg);
}
is failing with this error:
object.Exception at std/stdio.d(1321): Enforcement failed
----------------
./tester(pure @safe bool
std.exception.enforce!(bool).enforce(bool, lazy const(char)[],
immutable(char)[], ulong)+0x6b) [0x49a343]
./tester(ref std.stdio.File.LockingTextWriter
std.stdio.File.LockingTextWriter.__ctor(ref std.stdio.File)+0x59)
[0x4ce019]
./tester(@property std.stdio.File.LockingTextWriter
std.stdio.File.lockingTextWriter()+0x29) [0x4ce179]
./tester(void std.stdio.File.write!(immutable(char)[],
char).write(immutable(char)[], char)+0x69) [0x49b931]
./tester(void
std.stdio.File.writeln!(immutable(char)[]).writeln(immutable(char)[])+0x67)
[0x49b8bf]
./tester(void utils.log.Logger.writeMsg(immutable(char)[])+0x29)
[0x494631]
./tester(void utils.log.Logger.log(utils.log.LogLevel,
immutable(char)[])+0xa5) [0x4946dd]
./tester(void utils.log.Logger.logDebug(immutable(char)[])+0xa2)
[0x49455a]
./tester(_Dmain+0x52) [0x4a3862]
./tester(extern (C) int rt.dmain2._d_run_main(int, char**, extern
(C) int function(char[][])*).void runMain()+0x18) [0x4bf79c]
./tester(extern (C) int rt.dmain2._d_run_main(int, char**, extern
(C) int function(char[][])*).void tryExec(scope void
delegate())+0x2a) [0x4bf2ce]
./tester(extern (C) int rt.dmain2._d_run_main(int, char**, extern
(C) int function(char[][])*).void runAll()+0x40) [0x4bf7ec]
./tester(extern (C) int rt.dmain2._d_run_main(int, char**, extern
(C) int function(char[][])*).void tryExec(scope void
delegate())+0x2a) [0x4bf2ce]
./tester(_d_run_main+0x1ae) [0x4bf28a]
./tester(main+0x17) [0x4bf0d7]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)
[0x7f6bcc3f176d]
Also, I'm creating the logFile variable as follows:
File logFile = File(fileName, "w");
If ye need the code around it I'll be glad to post it, but the
logFile.writeln(msg) is the specific line it breaks on. If I
comment that out all is good.
It writes to the file once, and next time I call the function it
fails.
My guess is the lock on the file isn't releasing after the first
write?
More information about the Digitalmars-d-learn
mailing list