Likely closure memory corruption

deadalnix deadalnix at gmail.com
Sun Mar 3 08:48:31 PST 2013


auto objectSource = new FileSource("../libs/object.d");
auto object = lex!((line, index, length) {
	import std.stdio;
	writeln("new location 2 ! ", cast(void*) objectSource);
	
	return Location(objectSource, line, index, length);
})(objectSource.content);

Running this, I see that at some point, objectSource is changed. 
The output is
new location 2 ! 7F494EEC1D40
new location 2 ! 7F494EEC1D40
...
new location 2 ! 7F494EEC1D40
new location 2 ! 7F494EEC2EA0

Obviously, the program segfault soon after that.

It sounds like some memory corruption occurs under the hood. What 
can I do to work around that bug and to help solving it ?


More information about the Digitalmars-d mailing list