Open Geod24 opened 3 years ago
Even though it is supposed to be, eventcore is currently not fully @nogc
. There are still a few uses of built-in AAs, which should be replaced by a custom hash map implementation that doesn't use the GC. I didn't do it, yet, just because I didn't want to have vibe.d's HashMap
implementation lying around in a third place, but at the same time didn't feel like putting it into yet another container library or adding a dependency to one just for this purpose. But I guess ultimately some trade-off needs to be made here.
How do we work around this? I don't think using GC.disable()
is an option for us..
Upstream fix: https://github.com/dlang/druntime/pull/3301 But that will only work with v2.095.0+
How do we work around this?
Normally periodic tasks are resources, so you would store the timer somewhere, where you would be able to dispose it. Or self-dispose in the handler.
We had the unpleasant experience of tracking down a bug to this backtrace:
As you can see, some random code somewhere triggers a GC allocate (
frame #27
, doesn't matter where the allocation comes from), which triggers a collection (frame #20
), which collects a timer (frame #15
) which callsLoopTimeoutTimerDriver.releaseRef
(we're on POSIX). Inside this function, there's a call toAA.remove
: https://github.com/vibe-d/eventcore/blob/5e060d2d0b66b8462f1a7b6e05eee17b98e57d49/source/eventcore/drivers/timer.d#L200Well, that's a bad idea, because it can allocate...