So, somehow the memory was freed, in spite of the pointer to it still existing in the program inside new_context.stack_top. I should say that what I do is not the documented use of fibers, this one in particular finished already, but if anyone is interested, well, here you go.
Subclassing Fiber, patching scheduler, and in general storing fiber instances. I’m starting to think that last bit was a mistake, but why does the GC free the block that is still in use?
The issue I point was because the stack memory of the fibers are in a pool to reduce the stress in the GC. But they were marked as available in the pool before the fiber that was using it has finished. If this is not something that give some idea about what is going wrong in your scenario ignore it.
I think that’s indeed what’s going on. I was under the impression that stacks are under GC control, however their lifecycle is managed directly with Fiber::StackPool.