Repository navigation
Rescan a Deque whose items move during an incremental cycle (#424) - #443
Merged
Merged
Conversation
The verifier printed only the object it found unmarked, which says nothing about where the cycle lost it. It now records how its own walk first reached each allocation, and prints that chain back to a root, with each holder's type and whether this cycle marked it.
An incremental cycle scans an array of more than 256 items in chunks, which can run in any order. The runtime's Deque moves its items itself: a pop compacts the queue once the consumed part dominates, and a push at the front opens room by moving every item up. Either could carry items no chunk had reached into chunks already scanned, so the cycle left them unmarked, and the gc stress test's verifier aborted about once in 75 runs (libhxcpp #424). Both moves now open a mutation scope, as Array's own moves do, so the queue is scanned again. IncrementalGcDequeMoves stops a cycle partway through a 32768-item queue and makes each move; without the scopes the verifier aborts every run.
An incremental slice could find a new ThreadImpl on the creating thread's stack while its first array was being allocated, and the cycle could end at a later allocation in the initialiser list, before the constructor's barrier ran. The arrays stored in between were left unscanned and freed. The gc stress verifier caught it on Windows.
# Conflicts: # Changes.md
This was referenced Nov 13, 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.
Fixes the intermittent "Incremental GC omitted reachable object" in the gc stress test's incremental runs (#424), and a second gap of the same kind. The commits were first written on the
cppia-bugs-1106branch and are picked from there onto current main.Deque(sys.thread.Deque) moves its items itself: a pop compacts the queue once the consumed part dominates, and a push at the front makes room by moving every item up. Either could carry items no chunk had reached into chunks already scanned, so the cycle left them unmarked. Both moves now open a mutation scope, as Array's own moves do, so the queue is scanned again.IncrementalGcDequeMovesstops a cycle partway through a 32,768-item queue and makes each move. Without the scopes the verifier aborts on every run, on a node the report shows held by aDeque. It is added to the incremental regressions in test.yml.ThreadImplon the creating thread's stack while its first array was being allocated, and the cycle could end at a later allocation in the initialiser list, before the constructor's barrier ran. The arrays are now made in a mutation scope in the constructor body, before the thread starts. The stress verifier caught this one on Windows. There is no deterministic test for it.Reproduced here as in #424 (
bin/Stress 3 8 1337, built withHXCPP_GC_INCREMENTAL,HXCPP_GC_INCREMENTAL_VERIFY,HXCPP_GC_BIG_BLOCKSandHXCPP_M64, MSVC x64): main failed 2 of 150 runs with the omitted object, and this branch 0 of 750, the last 600 four at a time. At main's rate, 750 clean runs would happen by chance about once in 20,000.Fixes #424.