On Wednesday, 28 November 2018 at 22:40:17 UTC, unDEFER wrote:
Hello! After long-long time of debugging, I just have decided
InvalidMemoryOperationError in my program. But now my program
after few hours of testing again crashes with "Finalization
So InvalidMemoryOperationError means a GC function got called
while the GC was locked. This is usually because you did an
allocation inside a destructor.
Finalization error happens when a destructor throws an exception.
Now, many times, trying to throw an exception from inside a
destructor will first trigger the invalid operation - allocating
the exception will be an error before the exception actually
exists. But there are a few ways around this, like preallocating
or calling a function that uses a statically allocated exception.
Language features that use statically allocated exceptions
There might be more, but this is all I see right now (my process
btw: search the druntime source code for "staticError", the
function that makes those. But this is subject to change, so
first maybe look up the definition of onOutOfMemoryError and see
the pattern there.)
Of these... well, they are all kinda difficult to cause in a
Are you preallocating something in your code and throwing it in a
Also, what *exactly* is the message you get when the exception
happens? It should include a line number from druntime as well as
message from the inner exception that caused it in the first