Skip to content

A flow's value is no root once the flow has landed - #375

Merged
284km merged 1 commit into
mainfrom
rails-ar-flow-value
Nov 27, 2026
Merged

284km merged 1 commit into
mainfrom
rails-ar-flow-value

Conversation

@284km

@284km 284km commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Why

A return, break, next or throw on its way out is flow_sig's "k" together with "v" (and "tag", "fid"), and the collector marks the whole table as a root. When the flow lands, "k" is removed and the value belongs to the catcher, but "v" stayed behind and remained a root until the next non-local flow overwrote it. After two { |a| return a }, both values were alive, where ruby keeps no more than the last one.

What

The collector marks flow_sig only while "k" is present; otherwise it drops any "v" and "tag" left behind. This is safe because every reader checks "k" first or treats a missing "v" as nil, and every re-throw writes "v" together with "k".

Checked (Mere 9dec2ff6, main 391b560)

  • Corpus 1074: two returns out of blocks, one of them through a stored proc. It checks that the objects of at most one value are kept: main kept both, on the evaluator and the VM, index on and off. It also checks that the values of return, break, next and throw arrive whole.
  • Full corpus: 1013/1013 on the evaluator and the VM, index on and off, MERE_RUBY_SHAPES_CHECK=1.

Anything kept beyond ruby's one value comes from the conservative scan of the C stack (MERE_RUBY_GC_DBG=4 leaves nothing), not from this table. That is also why the YAML tree after a load is handled by #374, not here.

🤖 Generated with Claude Code

A return, break, next or throw on its way out is flow_sig's "k" with its
"v" (and "tag", "fid"), and the collector marks the whole table. Where the
flow lands, "k" goes and the value is the catcher's -- but "v" stayed, and
stayed a root until the next non-local flow wrote over it. After a second
`{ |a| return a }`, both values were alive where ruby keeps no more than the
last one.

The collector now marks the table only while "k" is there, and otherwise
drops a "v" and "tag" left behind; every reader asks "k" first, or takes nil
for a missing "v", and every re-throw writes "v" with "k".

corpus 1074: two returns out of blocks (one through a stored proc), and the
objects of no more than one value kept -- main kept both on the evaluator
and the VM, index on and off; and the values of return, break, next and
throw arriving whole.

(What is left beyond ruby's one value is the conservative scan of the C
stack: MERE_RUBY_GC_DBG=4 leaves none.)

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 809a81bcaa4b9a688bdac5056e18cdfdbb2aaf91 against fetched current main b9ca06d6700c44ded301131930a5dbd9107202be, including the flow producers/consumers, ensure unwinding, C API capture/resume and Fiber context save/restore. Existing reviews, discussion and inline threads were empty. No tracked AGENTS.md/CLAUDE.md is present. No new actionable finding established. Keeping active flows rooted while releasing inactive table payloads addresses the stale-root case without changing the delivered values in the checks below.

Independent Darwin arm64 validation: a fresh ordinary O2 build with pinned Mere 9dec2ff687a08433247dbdb7729bc19c8522e538 (clean compiler checkout) and the three imported mgz modules verified against 661a01d8. Binary SHA-256 1f708477861f550b8aaaab94eb9b8eb2362b8c4b9d042fbe9f1f964eaf559978; generated C 00a58ef5b592ec0e31c77fc4360c90546ddff14a7aec2b40754a3f2415bbeafd. All 40 head comparisons match clean Ruby 4.0.10 stdout, stderr and exit status: corpus 1074, 593, 829 and 907 plus an additional ensure/GC/Fiber probe, each on evaluator and strict VM, hash index ON/OFF, normally and under GC stress50 with tight GC. The additional probe covers heap-valued return/break/next/throw through allocating ensures, nested catch/throw, and a suspended Fiber's pending return.

The corresponding 40 current-main controls match all 32 neighboring/probe comparisons; only corpus 1074's retention predicate differs in all eight configurations (main false, reference/head true), with the delivered values unchanged. Main reused the previously verified O2 binary b2ebed47... after byte-checking all 2,781 tracked regular files against fetched main and verifying mgz inputs. Ten source gates, including GC roots and bracket depth (155/1024), and diff whitespace pass. No full-corpus rerun, complete upstream-file comparison, Rails fixture/RSS measurement or cross-platform resource acceptance is claimed; the description's full-sweep results remain author-reported evidence. This is exact-head validation, not a tested prospective main integration.

No merge: recorded hold_all_merges and new_failure_review_required remain active. The PR's executed Linux build job 140270195547 fails in the network-upstream guard for net/http/test_http.rb (reference 85 tests, exit 0; mere 85 tests, exit 1), the same guard/result shape recorded on earlier main job 140227703408; that does not establish identical individual test failures or a repair. Hosted macOS build/downstream acceptance remains incomplete. Latest current-main CI run 45916943242 is pending with zero jobs exposed, which does not clear prior failures. COMMENT because the authenticated account owns the PR.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 809a81bc. No Critical/Major/Minor findings. Once a non-local flow has landed (no "k"), its "v" and "tag" are dropped instead of being marked, so a return node out of a block no longer keeps that value alive until the next flow overwrites it. The readers all check "k" first or treat a missing "v" as nil. The review bot reviewed this head with no findings, corpus --both and the VM corpus are posted, and the test merge with current main is clean.

@284km
284km merged commit b1bb697 into main Nov 27, 2026
16 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant