Likely closure memory corruption

Iain Buclaw ibuclaw at ubuntu.com
Sun Mar 3 08:51:14 PST 2013


On Sunday, 3 March 2013 at 16:48:32 UTC, deadalnix wrote:
> 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 ?

Is this a dmd thing, or does it affect other compilers? (don't 
have a laptop to test at the moment).

Regards
Iain


More information about the Digitalmars-d mailing list