Repository navigation
Conversation
reardonj
force-pushed
the
cont-get-race
branch
2 times, most recently
from
November 6, 2026 23:35
1bc8e90 to
cd35ac1
Compare
Fixes a very narrow race condition when trying to `get` in an finalizer in a `Cont`. The implementation in IOFiber: 1. changed the cont state to waiting 2. concurrently, a running callback might check if the state is "waiting" (in `stateLoop`), see that it is, `loop()`, fail to resume, see the finalizing states disagree, and exit. The callback value is lost. 3. back in the fiber thread, it would update `wasFinalizing` on the cont state and wait for a callback that already terminated Now, `wasFinalizing` is set first. This ordering avoids the race.
reardonj
force-pushed
the
cont-get-race
branch
from
November 6, 2026 23:55
cd35ac1 to
a2b8776
Compare
Contributor
Author
|
As it happens, |
reardonj
marked this pull request as ready for review
November 7, 2026 01:59
reardonj
commented
Nov 7, 2026
| _ <- fiber.cancel | ||
| } yield () | ||
|
|
||
| one.parReplicateA_(if (!isJS) 8 else 1).replicateA_(50000) |
Contributor
Author
There was a problem hiding this comment.
This does take a significant number of tries to fail locally.
This branch has not been deployed
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.
Fixes a very narrow race condition when trying to
getin an finalizer in aCont. The implementation in IOFiber:waiting(instateLoop), see that it is,loop(), fail to resume, see the finalizing states disagree, and exit. The callback value is lost.wasFinalizingon the cont state and wait for a callback that already terminatedNow,
wasFinalizingis set first. This ordering avoids the race.This is probably quite obscure, but I hit this issue while working on #4710 , as I want to
getafter cancellation there.EDIT: fromCompletableFuture actually does use this pattern. Maybe #4469 is related. I also hit this bug on a separate PR trying to update the MacOS build, so I have folded the two together.