On Friday, 11 July 2014 at 11:43:44 UTC, Joakim wrote:
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio
wrote:
A code I'm working on stops working and starts printing an
infinite loop of
core.exception.InvalidMemoryOperationError
to the command line output. The code is quite complex and the
bug seems to present itself almost in random situation so I
would like to try to understand the issue better before
looking for the wrong line of code hiding somewhere. I've read
it might be that something is trying to allocate during a
destructor call, but it sounds really strange to me that
there's a neverending amount of exceptions being thrown. This
is the first exception being thrown (nothing is thrown before
the infinite loop begins).
Anyone has suggestions/ideas/heard of a similar stuff before?
If you look at the source for the garbage collector, the only
place that error is called is if the gc is trying to malloc or
execute other memory operations while the collector is running.
I ran across this myself because an assert was getting
triggered in a destructor. Since an assert tries to malloc and
the destructor is called by the GC, I got an
InvalidMemoryOperationError which swallowed up the message from
the original assert.
By putting printfs in the code path in druntime, I was able to
track it down to that destructor, otherwise I had no idea where
the invalid memory error was getting triggered. You can
probably do the same, but you can be sure it's a GC issue, and
I would guess tied to allocating in a destructor (unless you
happen to be calling InvalidMemoryOperationErrors somewhere in
your own code or some library that you're using, which is
unlikely).
It's unfortunate that you wrote this only 4 hours ago, because I
already spent the morning doing more-or-less the same thing, and
finaly realized what was happening and WHO was allocating during
a destructor. :o) It's even somewhat told in the docs of
core.exception module.
What I really don't understand is how the hell was it possible
that something managed to either recurse or loop to generate an
infinite WOE (Wall Of Exceptions).