Do not wait on freed fiber - #1773
Merged
bakpakin merged 1 commit intoJul 1, 2026
Merged
Conversation
Member
|
This looks at first glance correct, but the fact that this was missed tells me we should simplify the refcounting logic a bit. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a scheduler/event-loop liveness bug where a fiber that is manually suspended (via yield, not IO) can be garbage collected while still contributing to the event loop’s reference count, preventing the program from exiting (issue #1772).
Changes:
- Decrement the event loop listener/refcount when a GC-finalized fiber was previously marked as EV-suspended but has no
ev_state. - Preserve existing cleanup behavior for fibers with
ev_state(and Windows in-flight handling).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+339
to
+340
| } else if (f->gc.flags & JANET_FIBER_EV_FLAG_SUSPENDED) { | ||
| janet_ev_dec_refcount(); |
Contributor
Author
|
That is my feeling too... Let's just say that I am not very confident that this is the only issue of this kind |
bakpakin
marked this pull request as ready for review
June 30, 2026 00:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Possible fix for #1772.