The current implementation of GC is not re-enterable so users regularly receive an unexpected InvalidMemoryOperationError. The only reliable way to avoid this error is not to create garbage-collected instances of objects or structs with non-@nogc destructor. There is no information about it in the documentation, except error itself description. Nobody reads all possible errors descriptions before writing code. So then user faced this error usually it's too late to change architecture and think about ~this() @nogc.
So I propose to add info about this error and how to avoid this to destructors documentation page
https://dlang.org/spec/class.html#destructors
or as minimum write a short warning about and give the link to the page with extended info https://wiki.dlang.org/InvalidMemoryOperationError
Comment #1 by robert.schadek — 2024-12-15T15:24:10Z