Repository navigation
fix(core): treat a scope cgroup pruned during destroy as vacated - #192
Merged
Merged
Conversation
3 tasks
ElbertePlinio
force-pushed
the
fix/cgroup-teardown-prune-window
branch
from
September 22, 2026 22:47
92fdbf2 to
1a0235a
Compare
destroyCgroupMembers checked that the scope directory existed and then guardCgroupKill ran statfs, read cgroup.procs and wrote cgroup.kill on it. A concurrent createContainmentScope in another session prunes empty sibling scope cgroups, and a session that launched nothing has an empty scope, so the directory could vanish between those steps. Teardown then refused with "is not on a cgroup v2 filesystem", "could not read cgroup.procs" or "could not write cgroup.kill", left the session in error status and failed the desktop integration test when Vitest workers ran other session-creating files in parallel. A failed pre-kill check on a directory that existed when destroy began is now classified: if the directory is gone, the kernel only allowed that rmdir on an empty cgroup, so the scope is vacated and cleanup proceeds to the marker sweep with nothing killed. The entry can linger for under a millisecond while cgroup.procs already fails with ENODEV, so it gets a short bound to disappear; one that stays keeps its refusal. Ownership, evacuation and membership verification are unchanged and never decide "vacated" on their own. The preserved prune-race probe from #179 produced the refusal in about a third of empty-scope destroys on unmodified main and in none of 573 on this build. Closes #190
Review of the prune-window handling found two gaps. existsSync folds every inspection error into false, so a populated scope whose parent lost search permission after the initial existence check would have been classified as vacated and cleanup confirmed by the marker sweep alone. The absence probe now uses lstat and treats only ENOENT as gone; any other error keeps the refusal. A statfs that succeeds and reports a foreign filesystem is now a final refusal, even if that directory later disappears; only a statfs that could not answer may be the prune window. Regressions cover both, and the prune-site table gains the cgroup.procs read inside membership verification.
ElbertePlinio
force-pushed
the
fix/cgroup-teardown-prune-window
branch
from
September 23, 2026 16:03
1a0235a to
9dd41aa
Compare
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.
Closes #190
destroyCgroupMemberschecked that the scope directory existed, thenguardCgroupKillran statfs, readcgroup.procsand wrotecgroup.kill. A concurrentcreateContainmentScopein any other session prunes empty sibling scope cgroups, and a session that launched nothing has an empty scope, so the directory could vanish between those steps. Teardown then refused with "is not on a cgroup v2 filesystem", "could not read cgroup.procs" or "could not write cgroup.kill", left the session in error status, and failed the desktop integration test when Vitest workers ran other session-creating files in parallel.A failed pre-kill check on a directory that existed when destroy began is now classified. If the directory is gone, the kernel only allowed that rmdir on an empty cgroup, so the scope is vacated and cleanup proceeds to the marker sweep with nothing killed. The entry can linger for under a millisecond while
cgroup.procsalready fails with ENODEV, so a still-visible directory gets a 100 ms bound to disappear; one that stays keeps its refusal. Ownership, evacuation and membership verification are unchanged and never decide "vacated" on their own.Regressions in the simulated-cgroup suite: the three prune sites (statfs,
cgroup.procs,cgroup.kill) each confirm cleanup with nothing killed and no signals; a lingering entry with ENODEV is waited out; a path that exists but reports a non-cgroup filesystem magic keeps its refusal. The real-filesystem test for a plain directory outside cgroupfs already existed.Evidence on a delegated-cgroup host:
cgroup.procsfails ENOENT or ENODEV; in 14 cases the entry was still visible right after, and in all cases gone within 1 ms.packages/desktop-linux/test/integration.test.tspassed in it.