Skip to content

Restore JSON test loading through native alias visibility - #415

Merged
284km merged 5 commits into
mainfrom
codex-misc-json-load-regression
Dec 1, 2026
Merged

284km merged 5 commits into
mainfrom
codex-misc-json-load-regression

Conversation

@284km

@284km 284km commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Restore the CI evaluator JSON test loading by recognizing native method aliases during named visibility validation. OpenStruct conditionally executes private :block_given!; that alias lives in the native alias table, so checking only Ruby method definitions and builtin names raised NameError before the JSON files could start.

Minimal standalone shape (Ruby and the candidate load it; main raises NameError in the conditional):

class AliasVisibility
  alias_method :block_given!, :block_given?
  if true
    private :block_given!
  end
end

The native bisect between 85da98f and 491cc5c identifies 6152c4b (#346) as the first bad main commit. It predates the suspected #386/#388/#389/#390/#391 merges. #346 correctly routes named visibility statements through receiver dispatch (including Ruby overrides), but exposes the ordinary call validator's missing alias lookup. The fix keeps that dispatch and adds a lookup in the actual receiver ancestors, guarded by the known-alias name set and undef tombstones. Unrelated classes' aliases cannot satisfy validation.

CI unittest-report evidence:

Main parser / addition / generic_object State
85da98f, run 45721708316 53 / 13 / 5 MATCH all COMPLETE, exit 0
491cc5c, run 46078134440 0 / 0 / 0 discovered all INCOMPLETE, exit 1, no summary

The bad logs report exception propagates after ensure. A bounded focused load exposes its underlying exception: NameError, undefined method block_given! for class OpenStruct, at ostruct.rb:490. This is a load failure rather than a long-running JSON test or memory timeout. Native first-parent bisect, same pinned O2 compiler/dependency and original parser file with seed 1:

Revision Result
3fbe392 53 tests, 1,811 assertions, no failures/errors/skips
83bc573 53 tests, 1,811 assertions, no failures/errors/skips
e969c49 53 tests, 1,811 assertions, no failures/errors/skips
6152c4b exit 1, no tests/summary; same ensure failure
29016cb exit 1, no tests/summary; same ensure failure

Corpus 1165 covers named private/public/protected changes to native aliases in a conditional, inherited/included/singleton aliases, undef shadowing, unrelated-owner rejection and Ruby visibility overrides. Both engines match the reference, including GC stress. Existing controls 307, 407, 959 and 1124 remain matching on both revisions/engines. Real OpenStruct integration is exercised through the original JSON test load paths, rather than adding a gem dependency to the standalone corpus.

Original CRuby files are unchanged, each run separately under the normal unittest/try.sh load paths, fixed seed 1 and unchanged 2 GiB / 600 s bounds. Cells show tests / assertions; failures/errors/skips. The table records actual results on reference and both baseline/candidate engines; a main VM pass is preserved, rather than assuming both main engines fail.

File Reference Main evaluator Main VM Candidate evaluator Candidate VM
json/json_parser_test.rb 53 / 1811; 0/0/0 exit 1, no summary 53 / 1811; 0/0/0 53 / 1811; 0/0/0 53 / 1811; 0/0/0
json/json_addition_test.rb 13 / 40; 0/0/0 exit 1, no summary 13 / 40; 0/0/0 13 / 40; 0/0/0 13 / 40; 0/0/0
json/json_generic_object_test.rb 5 / 26; 0/0/0 exit 1, no summary 5 / 26; 0/0/0 5 / 26; 0/0/0 5 / 26; 0/0/0
ruby/test_module.rb 6 / 48; 0/0/0 6 / 48; 0/0/0 6 / 48; 0/0/0 6 / 48; 0/0/0 6 / 48; 0/0/0

The module selection is test_s_public/test_s_private/test_s_protected/test_private_class_method/test_public_class_method/test_alias_method. No full unit-test or Rails component suite was run. Reference: clean ruby 4.0.10 through tools/ref_ruby.sh, revision a704b7cd; no gems installed. Baseline main 98aa453. Mere 9dec2ff6, mgz 661a01d8, ordinary O2. Candidate binary SHA-256 84dd73c21fe3fb54e90340dd81845b23d1d45a0fceda3f5df384d322a4cea6d6. The sealed native binary is reused after fixture-only corrections with all compiler/runtime/generated inputs unchanged; all final tracked code/test/dependency input hashes are checked before and after validation. Evaluator runs leave MERE_RUBY_VM unset.

  • sh run_corpus.sh --both: 1041/1041 corpus programs match ruby, index on/off.
  • MERE_RUBY_VM=1 sh run_corpus.sh --both: 1041/1041 corpus programs match ruby, index on/off.
  • MERE_RUBY_VM=1 sh tools/iseq/vm_corpus.sh -j 2: vm_corpus: 1041 programs -- 1041 on the VM, 0 on the evaluator (fell back), 0 FAIL, 0 against the list of fallbacks.
  • All source gates pass: StrBuf regions, GC roots, duplicate/dead definitions, method writes, ivar door, names/namespaces/lengths, regexp captures and bracket depth. Packed GC mark checks pass under O2 and ASan/UBSan; record_hygiene and whitespace checks pass.

Common named-visibility costs: bench/native_alias_visibility.rb 2000 --seed=1, MERE_RUBY_GC_TIGHT=1, three alternating baseline/candidate pairs per engine, plus count-0 controls (24 runs). Per-call instructions subtract median startup/control from median count-2000 run and divide by 4,000 private/public calls. RSS is the maximum of three count-2000 runs, MiB. A failing baseline JSON load is not used as an equivalent peak-RSS workload.

Engine Instructions/call, main → candidate Change Max RSS MiB, main → candidate
evaluator 24,272.7 → 24,225.5 -0.194% 69.703 → 69.672
VM 24,997.0 → 25,682.3 +2.741% 70.469 → 70.469

A longer repetition control uses 20,000 iterations / 40,000 named visibility calls, the same startup subtraction, three alternating pairs and fixed-seed GC_TIGHT (another 24 runs). The candidate's alias lookup follows the existing Ruby/builtin checks, so these Ruby-defined methods keep their existing validation path. The longer measured comparison is:

Engine Instructions/call, main → candidate Change Max RSS MiB, main → candidate
evaluator 23,231.9 → 23,222.3 -0.041% 69.688 → 69.656
VM 24,215.0 → 24,263.4 +0.200% 70.484 → 70.469

All four selected original files additionally match their Ruby 4.0.10 Git blobs byte-for-byte after testing. No GC/arena policy or workflow changes are included. Local validation is complete; exact-head review and hosted CI remain.

@284km
284km marked this pull request as ready for review November 30, 2026 08:46

@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 head 9ec9ea55b8663edbe88cc8a200dc8a11503c2761 against current main f0f372e7dc00967ae881f599eae68758648a9148. No new actionable code findings in this diff. The receiver-ancestor lookup and undef guard keep unrelated aliases from satisfying named visibility validation, while retaining ordinary receiver dispatch and Ruby overrides.

Independent validation on Darwin arm64:

  • Corpus 307, 407, 959, 1124 and 1165: 40/40 exact reference comparisons across evaluator/VM and normal, hash-index-off, MRO-cache-off and GC-stress configurations.
  • Ran all three unchanged original JSON files separately through the normal unittest load paths with seed 1. Reference Ruby 4.0.10 and both candidate engines pass: parser 53 tests / 1,811 assertions; addition 13 / 40; generic object 5 / 26, all with zero failures/errors/skips. Each original matches its pinned upstream Git blob.
  • Built current main freshly at ordinary O2 with Mere 9dec2ff6 and the pinned mgz inputs. Its evaluator exits 1 before a summary in all three JSON files; its VM passes the same 71 tests / 1,877 assertions. The candidate therefore restores evaluator loading and preserves the passing VM results. Four existing corpus controls also match on both main engines.
  • Candidate O2 binary 84dd73c21fe3fb54e90340dd81845b23d1d45a0fceda3f5df384d322a4cea6d6 was reused after comparing all 1,831 recorded inputs plus the build configuration against this head, and verifying the clean pinned compiler identity/hash. GC-root accounting (matching generated C), dead-definition, method-write and namespace gates pass.

These are focused review checks, not a new complete corpus, full upstream suite, or memory acceptance run. Hosted Linux build/tests and a macOS gem job are still running; other macOS/reference jobs remain queued and downstream matrices are incomplete. Inspected every job of the latest main CI run 46362164472: build-linux fails its complete Module check (195 tests, 1,234 assertions, 0 failures, 2 errors); the VM comparison job is skipped. This pre-existing result is not attributed to this PR or claimed repaired.

No merge: the recorded hold_all_merges / new_failure_review_required flags remain active, and running or missing hosted coverage is outside the unassigned-runner queue exception. The same policy also keeps the already-reviewed open merge candidates on hold. COMMENT because this review account owns the PR.

@284km
284km merged commit 3c58e04 into main Dec 1, 2026
39 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