Guard against leaking threads while restarting Shake - #38
Draft
soulomoon wants to merge 13 commits into
Draft
Conversation
This was referenced Aug 11, 2026
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.
Alternative ownership model for haskell/haskell-language-server#5027.
Summary
AIOscope once cleanup begins so late children cannot register into a drained scopebuildcallsWhy
A force runner can select a
Runningforce while its AIO scope is open, then remain parked until after cleanup closes that scope. After the build step advances,viewDirtyprevents deliberate reuse of the oldRunningforce, so the race is limited to work that selected the force before teardown.Upstream allows that selected force to register a child into the already-drained scope. The build waiting on the child can then be cancelled while the child remains alive with no scope left to own or cancel it.
This change assigns one cancellation owner to each outcome: cleanup cancels admitted threads; refused threads never enter the registry, do not execute their bodies, and finish normally. The already-admitted parent waits for external scope cancellation instead of trying to kill the same work a second time.
Regression test
The test makes the out-of-scope lifetime deterministic:
Runningforce but remains in key traversal.With upstream
masteratb7e5d2526, the late child remains alive and the test fails withexpected: False/but got: TrueforoutOfScopeAlive. The test releases and joins that orphan before reporting RED, so the test itself leaks nothing. With this branch, admission is refused before the rule body starts and no out-of-scope child exists.Validation
cabal test hls-graph:test:tests -fpedantic --test-show-details=direct --test-option=-p --test-option='/does not leave a late async/'cabal test hls-graph:test:tests -fpedantic --test-show-details=directhls-graphtests passedgit diff --checkThe branch is rebased onto upstream
masteratb7e5d2526.