test(kernel): regression test for circular-print mark restoration#23
Merged
Conversation
PR #20 added the fe_write() cycle-detection fix (borrow GCMARKBIT, clear it in unmarkpairs) but shipped no test for it. This closes that gap. The mark bit lives in the low byte of a pair's car field, so a leaked mark corrupts the car pointer — which makes walking the structure after repr a direct, deterministic check of mark restoration (no GC needed). repr also runs fe_write twice internally (measure + fill), so a stale mark would skew the two passes. Verified the test has teeth: neutering unmarkpairs to a no-op makes the walkability checks segfault (exit 139), which ctest scores as a failure. 20/20 ctest, 23 checks in the kernel file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
PR #20 added the
fe_write()circular-structure fix (borrowGCMARKBITduring traversal, clear it afterward inunmarkpairs) but shipped no test for it. This adds the missingkernel/circular-printregression test.Why this is a strong test
The mark bit lives in the low byte of a pair's
carfield. So a leaked mark bit doesn't just leave stale state — it corrupts the car pointer. That makes walking the structure afterrepra direct, deterministic check of mark restoration, with no need to force a GC (which would be flaky across arena/pool sizes):(is (repr x) "(1 2 3 ...)")— tail-cycle prints finite, ends in...(is (repr y) "(... 2 3)")— head-cycle (setcarself-reference)(is (cdr (cdr (cdr x))) x)— the cycle still closes onx(pointer identity intact)(is (car (cdr (cdr (cdr x)))) 1)— walking through the back-edge returnsx[0](is (repr x) (repr x))— reprʼing twice yields the same string (marks don't accumulate)repralso runsfe_writetwice internally (measure pass + fill pass), so a stale mark would skew the two passes and corrupt the output — another angle the same test covers.Verified the test has teeth
Neutering
unmarkpairsto a no-op (cycle-detection still works, so it doesn't merely hang) makes the post-print walkability checks segfault (exit 139) — ctest scores that as a failure. With the real fix restored, 20/20 ctest, 23 checks in the kernel file. Kernel source is untouched — test + CHANGELOG only.🤖 Generated with Claude Code