Repository navigation
[core] retain resource cleanup across acquisition interrupts - #1954
Closed
DamianReeves wants to merge 1 commit into
Closed
DamianReeves wants to merge 1 commit into
DamianReeves wants to merge 1 commit into
Conversation
Register release when acquisition returns, before interruption can abandon the continuation. Release late acquisitions on a detached fiber when their scope has already closed.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
#1954 closes, on the old kernel, the window between an acquire producing its value and the release being registered, through a completion observer; this branch closes the same window structurally, since Scope.acquireRelease registers through ensureMap. The PR is superseded by the new kernel, and its five regression leaves were compared against what this branch already pins. Taken, because the branch had no leaf for them: - a typed Abort failure in the acquire registers no release (the branch pinned only the throw); - the Closed a refused registration raises names the scope's creation frame, folded into the existing closed-scope leaf, which also stops accepting a success there: with the gate opening after Scope.run has returned, the refusal is the only correct outcome; - a refused release that suspends and then fails still runs exactly once, and the acquiring fiber's error stays the refusal rather than the release's failure. Not taken: the interrupt-in-the-final-step and suspended-acquisition leaves, already covered by the #1224 and #1820 sections and by ScopeInterruptTest; and the PR's assertion that a Scope.ensure refused by a closed scope does not run, which contradicts this branch's contract of running a refused registration detached rather than dropping it. Verified: ScopeTest green on JVM (76 leaves) and JS (75) in a copy of this tree; the run in this tree is in progress at commit time.
Collaborator
|
I'm preparing to open a PR with the new arrow-based kernel and it has major changes in how this code works. I'll close this PR since the new kernel fixes this issue as well. |
fwbrasil
pushed a commit
that referenced
this pull request
Sep 18, 2026
### Problem The JavaScript WeakReference shim was also compiled for Scala Native, shadowing its runtime implementation. That broke reference casts and inherited thread-local copying, including the runtime stack-unwinding buffers. ### Solution Restrict the shim to JS and Wasm. Add regressions for clearing references, replacing cleared registry entries, and child-local inheritance. Enable Native machine-metric readback tests and remove the scheduler tests' exception suppression. ### Notes Validated on this standalone branch: 282 registry tests across JVM, Native, JS, and Wasm; three machine-metric tests each on JVM and Native; both README doctests; and serial `scalafmtCheckAll`. The three Native weak-reference regressions reproduced the original defects before the fix. Extracted from #1868 so the filesystem stack can be reviewed independently. Rebased onto `6d50eecae` on September 17. Revalidated all 282 registry tests across JVM, Native, JS, and Wasm, plus six machine-metric tests across JVM and Native. The previous Linux JVM CI failures are addressed separately in #1953 and #1954.
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.
Scope.acquireReleasecould produce a resource and then lose its cleanup when the fiber was interrupted before the registration continuation.Fiber.inituses this path, so a child that had already started could survive its parent scope's shutdown.Register the release in the same step that receives the acquired value, using a private kernel completion observer. Suspended acquisition stays interruptible. If the scope already closed, run the rejected release exactly once on a detached fiber and retain the
Closederror. Public effect rows andScope.ensurerejection behavior remain unchanged.Investigated after #1949's Linux ARM64 JVM job reported no reclaim events after interrupting a SQL lease's parent. A deterministic core regression interrupts inside the final acquisition step and observes scope teardown: acquisition ran once, release ran zero times. It fails directly in 16 ms before the fix. This proves the core defect independently; the CI log does not establish its exact interleaving.
Shared regressions cover interruption during acquisition, a scope closing before acquisition completes, rejected asynchronous cleanup failure, acquisition failure/panic, exactly-once release, and the original scope creation frame in
Closed. The existing closed-scope acquisition regression is enabled.Validation:
scalafmtCheckAllandgit diff --checkpassed.