Tracing down core.exception.InvalidMemoryOperationError

Joakim via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 28 05:09:28 PDT 2014


On Monday, 28 July 2014 at 09:38:35 UTC, Martin Drasar via 
Digitalmars-d-learn wrote:
> Hi,
>
> at the end of my program it throws InvalidMemoryOperationError. 
> Looking
> at the documentation and past forum questions I learned that it 
> is
> probably because of allocations in destructors. However, I have 
> no such
> thing in my code (at least not intentionally). I am suspecting 
> the
> std.logger package, because it throwed on me a memory error on
> occasions. But regardless of the source, I would like to trace 
> it and
> deal with it. But I do not have much of an idea where to start. 
> Could
> you give me an advice?

More broadly speaking, it is thrown whenever certain memory 
operations are attempted while the GC is running, 6 in all, as 
you can see here:

https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gc.d#L458

I believe I stuck in printfs till I found out which one was run 
before the error was thrown, and then traced that back with more 
printfs to where it was getting called.  I didn't have a debugger 
available, you may be able to trace faster with one.


More information about the Digitalmars-d-learn mailing list