ysbaddaden/execution_context

event_base_loop: reentrant invocation

Closed this issue · 3 comments

[warn] event_base_loop: reentrant invocation. Only one event_base_loop can run on each event_base at once.

It got the issue last week, but it seems it's still possible to happen:
#15 (comment)

That needs to be investigated.

Ideally the event loop would return the list of runnable fibers, so the schedulers can enqueue them in single operation (minus one to resume immediately), not execute a callback for each fiber that individually enqueues each fiber one by one, then have to dequeue one.

In the meantime, maybe the event loop callbacks could bypass Fiber#enqueue and call ExecutionContext::Scheduler#enqueue directly?

This is the problematic call:
https://github.com/ysbaddaden/execution_context/blob/main/src/single_threaded.cr#L156

Which means only ST is affected. MT prefers to switch to unblock the current fiber (to avoid delays if another thread picks it), while ST can avoid the switch.

Should be fixed by 647ed93