From b6e9099dc342902e87ad85712ea0e2fd60b51c95 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 02:11:16 +0700 Subject: [PATCH] lab_t27b_ratchet: the usize scratch arrays start at zero, so the t27b interpreter reads no byte that was never written (Closes #11131) t27b test --check on the spec printed MISMATCH the_ratchet_equals_the_pythons_checker_on_every_case: jit Ok(1), interpreter Fault("8-byte read at stack+0x6ff8 of bytes never written") and 1 JIT/interpreter mismatch, which made the t27b-native-ratchet of every PR read jit/interp mismatch 1. Nine [3]usize scratch arrays were declared with no value; they are now [0, 0, 0]. After the change t27b test --check exits 0 with no mismatch (the interpreter runs 1824 runtime asserts, it stopped at 794 before) and the 14 tests pass. Co-Authored-By: Claude Sonnet 5.5 --- specs/lab/lab_t27b_ratchet.t27 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/specs/lab/lab_t27b_ratchet.t27 b/specs/lab/lab_t27b_ratchet.t27 index 5289710d06..861085fcc7 100644 --- a/specs/lab/lab_t27b_ratchet.t27 +++ b/specs/lab/lab_t27b_ratchet.t27 @@ -437,7 +437,7 @@ pub fn lt_run_val(run : string, o : usize, e : usize, key : string, sp : []usize /// The verdict code of key (`t27b` or `reference`) of the result t[o..e]. pub fn lt_run_word(run : string, o : usize, e : usize, key : string) -> u8 { - var sp : [3]usize = undefined; + var sp : [3]usize = [0, 0, 0]; const f : bool = lt_run_val(run, o, e, key, &sp); return lt_word_of(run, f, sp[0], sp[1], sp[2] == 1); } @@ -468,7 +468,7 @@ pub fn lt_first_text(run : string, o : usize, e : usize, sp : []usize) -> u8 { } sp[0] = 0; sp[1] = 0; - var d : [3]usize = undefined; + var d : [3]usize = [0, 0, 0]; if (lt_run_val(run, o, e, "detail", &d) == false) { return 1; } if (d[2] == 1) { sp[0] = d[0]; @@ -494,7 +494,7 @@ pub fn lt_collect_entries(ledger : string, ent : []u32, cap : usize) -> usize { } if (start == LAB_NO) { return 0; } var n : usize = 0; - var sp : [3]usize = undefined; + var sp : [3]usize = [0, 0, 0]; var s : usize = start; var closed : bool = false; while (s < ledger.len and closed == false) { @@ -533,7 +533,7 @@ pub fn lt_collect_results(run : string, rt : []u32, cap : usize, flag : []u32) - flag[0] = 0; var n : usize = 0; var o : usize = next_object(run, results_at(run)); - var sp : [3]usize = undefined; + var sp : [3]usize = [0, 0, 0]; while (o < run.len) { const e : usize = object_end(run, o); const v : usize = key_at(run, o, e, 3, "file"); @@ -727,9 +727,9 @@ pub fn lt_ratchet(run : string, ledger : string, work : []u32, cap_e : usize, ca ledger_commit = key_at(ledger, src[0], src[1], 2, "commit"); } var x : usize = w; - var sp : [3]usize = undefined; - var bsp : [3]usize = undefined; - var lsp : [3]usize = undefined; + var sp : [3]usize = [0, 0, 0]; + var bsp : [3]usize = [0, 0, 0]; + var lsp : [3]usize = [0, 0, 0]; var i : usize = 0; while (i < me) { const ei : usize = eord[i] as usize; @@ -793,7 +793,7 @@ pub fn lt_ratchet(run : string, ledger : string, work : []u32, cap_e : usize, ca x = lab_put_lit(out, cap, x, "the reference does not pass it any more ("); x = lab_put_lit(out, cap, x, lr_word(ref_c)); x = lab_put_lit(out, cap, x, ": "); - var dsp : [3]usize = undefined; + var dsp : [3]usize = [0, 0, 0]; if (lt_run_val(run, o, e, "reference_detail", &dsp)) { if (dsp[2] == 1) { x = lt_put_json(out, cap, x, run, dsp[0], dsp[1], 120); @@ -1100,7 +1100,7 @@ test repr_chooses_its_quote_and_escapes_as_python_does { } test a_one_line_object_is_read_for_its_last_key_and_a_bad_line_is_not_read { - var sp : [3]usize = undefined; + var sp : [3]usize = [0, 0, 0]; const row : string = "{\"path\": \"x\", \"t27b\": \"pass\", \"n\": [1, {\"k\": \"}\"}], \"z\": 7, \"t27b\": \"fail\"},"; assert lt_obj(row, 0, row.len, "t27b", &sp) == 1; assert sp[2] == 1;