Repository navigation
fix(ocap-kernel): sort GC krefs before hardening them - #1082
Merged
Merged
Conversation
2 tasks done
sirtimid
force-pushed
the
sirtimid/gc-sort-krefs-before-harden
branch
from
September 18, 2026 17:19
b32de04 to
7435e1e
Compare
`processGCActionSet` sorted the kref list `filterActionsForProcessing` had already hardened, so any endpoint with two pending actions of one type threw a TypeError out of the run loop. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
sirtimid
force-pushed
the
sirtimid/gc-sort-krefs-before-harden
branch
from
September 18, 2026 17:36
7435e1e to
1355e60
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.
processGCActionSetsorted the kref list afterfilterActionsForProcessinghad hardened it.Array.prototype.sortwrites every element back even when the array is already in order, so any endpoint with two pending GC actions of one type threw aTypeErrorout of the run loop. One vat dropping two exports in a crank was enough, and it reproduces onmain.Re-landed from #1022 as part of the split of #1021–#1023 into single-defect PRs.
Changes
filterActionsForProcessingsortskrefsbefore theharden; the sort inprocessGCActionSetis gone.groups two actions of one type for one vat into a single item.@metamask/ocap-kernel.Testing
The new test fails on
mainwithTypeError: Cannot assign to read only property '0'and passes with the fix. The full@metamask/ocap-kernelunit suite passes locally.🤖 Generated with Claude Code
Note
Low Risk
Small, localized GC ordering fix with a targeted regression test; avoids mutating hardened arrays without changing GC semantics beyond stable kref ordering.
Overview
Fixes a run-loop crash when one endpoint has two or more pending GC actions of the same type (e.g. a vat dropping two exports in one crank).
filterActionsForProcessingnow sortskrefsbeforeharden, because sorting a frozen array throws. The duplicate sort inprocessGCActionSetis removed; the returned queue item still hardens a copy of the sorted list (krefs: [...krefs]).Adds a regression test that groups two
dropExportactions for one vat into a singledropExportsitem, and documents the fix in the package changelog.Reviewed by Cursor Bugbot for commit 1355e60. Bugbot is set up for automated code reviews on this repo. Configure here.