fix(kernel): apply three upstream rxi/fe patches#20
Merged
Conversation
- fe_write() now detects and prints "..." for circular structures instead of looping forever / stack-overflowing (upstream PR #22). Relevant for the REPL where setcar/setcdr can produce circular lists. - Comment parser now terminates on \r as well as \n, fixing parse corruption with Windows-style CRLF cart source files (upstream PR #25). - fe_savegc() in fe_open() now precedes the t symbol allocation, closing a theoretical GC-during-init window (upstream PR #25). All 19 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jschairb
added a commit
that referenced
this pull request
Jun 15, 2026
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
Applies three correctness fixes from open (but unmerged) upstream rxi/fe PRs to
kernel/fe.c. The upstream repo is effectively unmaintained — we vendor the kernel directly — so this is the right place for these.fe_write()(rxi/fe#22):fe_write()would infinite-loop / stack-overflow on any circular pair structure. Relevant now that the REPL is first-class —(setcar ...)/(setcdr ...)can trivially produce one. Fix borrowsGCMARKBITduring traversal to detect cycles, prints...in place of the back-edge, then immediately clears marks.\rcomment termination (rxi/fe#25 partial):;comment parser stopped only on\n, so a\r\n-encoded cart source file would swallow the\rinto the next token. One-character fix.fe_open()(rxi/fe#25 partial):fe_savegc()was called afterfe_symbol(ctx, "t"), leaving a window where GC during that allocation could collect the freshtobject before it was stored inctx->t. Moved the save to before the allocation.The delimiter change also in PR #25 was intentionally skipped — KEC's kernel already carries a different (extended) delimiter set.
Test plan
cmake --build build— clean compile, zero warningsctest --test-dir build --output-on-failure— 19/19 passed🤖 Generated with Claude Code