mem_diff: narrow skip catch to UnsupportedConstruct, guard memory/export compares, deduplicate families #1679
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1679
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mem-diff-compare-and-harness-errors"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Item ID:
MEM-DIFF-COMPARE-AND-HARNESS-ERRORS(claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156347986)Summary
run_fragmentskip handling (tools/mem_diff.py):spirv_mini_interp.UnsupportedConstructinstead of broadExceptioninrun_one()(matchingtools/shader_diff.py), so real interpreter/harness failures (RuntimeError,AssertionError,KeyError, etc.) surface asharness-error(exit2) instead of being silently downgraded to"skip".IndexErrorcrashes inrun_one()comparison logic:(memory.get(a, 0) & MASK32) != (ref.mem.get(a, 0) & MASK32)) before indexingbad[0], preventing anIndexError: list index out of rangewhenever one side explicitly stores0at an unseeded address absent from the other side.%out_mrt0exports (len(got) > 4whose first 4 words matchwant) by reporting"export shape mismatch: expected 4 words, translated N"instead of crashing onbad[0], and mask exported words to 32 bits (MASK32).--familyselections:familiesviasorted(set(families))ingenerate_program()so repeated--familyflags do not skew random family sampling.tests/test_mem_diff.py):CompareAndHarnessRegressioncoveringUnsupportedConstructvs unexpectedRuntimeErrorharness error, zero-valued extra memory entries, overlong%out_mrt0exports, and duplicate--familydeduplication.Checklist & Verification
python3 -I scripts/check_no_game_data.py tools/mem_diff.py tests/test_mem_diff.pypassed)python3 -W error -I tests/test_mem_diff.py -v:Ran 23 tests ... OKCompareAndHarnessRegressionagainst unpatchedmaintools/mem_diff.py):Ran 4 tests ... FAILED (failures=1, errors=3)python3 -m compileall -q make_game.py tools tests: passedpython3 -I tests/test_text_write_line_endings.py:Ran 3 tests ... OKIndependent review (CPU-only Windows 11, python 3.14.9
python -I, fresh clone; headc064f0718, current main57ba40bd6).Coordination. Claim comment 7156347986 (IlyassRS3, 2026-11-25T07:52:26Z) predates the PR (created 07:55:04Z). The #1608 roster shows
MEM-DIFF-COMPARE-AND-HARNESS-ERRORS -> #1679, andgh pr list --search "mem_diff" --state allreturns exactly this PR — no duplicate work.The new test bites (inverse check).
tests/test_mem_diff.pyat head:Ran 23 tests ... OK(the file at main runs 19, so +4 exactly as claimed). The same test file against main'stools/mem_diff.py:FAILED (failures=1, errors=3), and the errors name the real crashes —IndexError: list index out of rangetwice (zero-valued extra memory entry and overlong%out_mrt0export), and the missingUnsupportedConstructname. All 19 pre-existing tests stay green against main, so the delta is fully localized to the newCompareAndHarnessRegressionclass.Whole-suite check. Clean main
57ba40bd6: 915 test files emitting unittest output, 13,976 tests, 6 pre-existing red files (test_bink_names, test_opus_tags, test_runner_calls_all_tests, test_runtime_paths, test_tool_stdout_encoding, test_world_names — all red on main itself, untouched by this PR). On the pr1679 branch tree: 914 files / 13,972. That −8 is noise from the branch base, not a regression: pr1679 is based on3f81d46acand predates the #1493 merge that addedtests/semantic/test_valu_signed_literal64.py(−8) to main; +4 is the new class. Failing-file sets are identical (plus one flakytest_run_wine_testserror on the branch run only — that file is byte-identical on both trees).Mergeability.
git diff 3f81d46ac..origin/mainover the PR's two files is empty — main's moves since the base (#1493 etc.) touch disjoint files, so this rebases clean. (GitHub still reportsmergeable: UNKNOWNat posting time; the checkschange-scopeandno-game-datawere pending at head when I looked.)Code notes.
except UnsupportedConstructmatches the siblingtools/shader_diff.pyexactly (same import form at its line 42, same catch at its line 252). Worth knowing:spirv_mini_interpalso raisesInvalidModule(anAssertionErrorsubclass),UndefinedResult, andValueError, which the old broadexcept Exceptionsilently turned intoskip; these now surface as harness errors (exit 2). That's the item's stated intent — bad module shapes and undefined lane reads are harness bugs, not untested constructs — and it matches the rest of the tool family, so not a concern, just flagging the reclassification.badwith unmasked!=only aftermemory != ref.mem, so a zero at an address present on one side only crashed onbad[0]; the new code masks both sides and guards the empty list, and the export compare now masks words toMASK32and reportsexport shape mismatch: expected 4 words, translated Nfor overlong exports instead of crashing.sorted(set(families))dedup verified:generate_programwithfamilies=["s_load","s_load","s_load","global"]reproduces the same lines/memory as the deduped call; without dedup main skews the family sampling.python -I scripts/check_no_game_data.py tools/mem_diff.py tests/test_mem_diff.pyexits 0;compileallclean on both files.Verdict: LGTM — the four fixes are real crash fixes against the interpreter's known raise types, the regression tests bite only on unpatched main, and the branch rebases onto current main with zero file overlap.
AI-assisted (Hermes overnight shift). Environment: Windows 11, python 3.14.9
-I, no GPU involved.Red/green: the PR tests fail on main (1 failed) and pass on head c064f0718e42 merged with main (23 passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)