decomp: preserve CHANSVm string-load deletion errors #963

Merged
coah80 merged 1 commits from agent/bittle/chansvm-string-error into main 2026-10-02 21:35:32 +00:00
coah80 commented 2026-10-02 21:34:24 +00:00 (Migrated from github.com)

Decompilation correction

Under the requested decompilation-first phase, this fixes a real CHANSVmStep behavior mismatch without claiming a newly exact function or native linking gain.

LOAD_STRING_CONST previously overwrote every CHANSVmDeleteObject failure with CHANS_VM_ERR_LOAD_STRING_CONST (-945). The target preserves a deletion failure and only returns -945 when deletion succeeded but the constant index/payload is invalid. A scoped loadResult and normal conditional merge now preserve those paths. No headers, linking flags, symbols, splits, data, or assembly changed.

Target evidence independently checked

CHANSVmStep-relative offsets: +0x9fc calls DeleteObject; +0xa04 branches directly to +0xa64 on nonzero return; +0xa64 preserves r3. Invalid string checks at +0xa24/+0xa38 alone select -945 at +0xa3c. Source-extracted host C tests passed six cases (missing operand, deletion failure with valid/invalid index, invalid index, null payload, success). This is a stubbed behavior harness, not Wii runtime execution.

Fresh rebased validation on d725e023

  • CHANSVm decompiled/fuzzy 99.364426% → 99.383840%; Step 96.466080% → 96.673584%.
  • Step instruction counts 1253/1253; differing positions 314 → 297. Still non-exact.
  • Exact functions 221/233, exact code 37608/53564 and exact data 6904/6904 unchanged. No function/unit regressions.
  • All 1027 allocated native objects audited: only CHANSVm .text changed, size 53564 unchanged; all 1396 text relocations unchanged; all data unchanged.
  • Pool 125/125 identical. Literal audit:233 functions,40 arguments,zero candidates/errors/skips.
  • Full all_source/progress/report/DOL check passed; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
  • Tests workflow8/literal36/jump-table27/pool8 passed; main and leaf worktree checks pass.
  • Remote tree20f36c118adf919936736481b44abad1fe24de36 equals tested local tree.

No register/volatile forcing, fabricated padding, uninitialized values, retail assembly transplant or score redefinition. Twelve CHANSVm functions remain non-exact. Left for review; no merge performed.

Note

Fix CHANSVmStep to preserve accumulator deletion errors in LOAD_STRING_CONST

The LOAD_STRING_CONST path in CHANSVm.c used a shared goto flow that overwrote the error from CHANSVmDeleteObject. The step now stores that deletion result in a local error variable, validates the constant index and string payload only after deletion succeeds, and returns the preserved deletion error when deletion fails. Also adds a validation report in CHANSVm.allhands-load-constant-attempts.md covering binary-diff and harness results.

Macroscope summarized 8cd2f7f.

## Decompilation correction Under the requested decompilation-first phase, this fixes a real CHANSVmStep behavior mismatch without claiming a newly exact function or native linking gain. LOAD_STRING_CONST previously overwrote every CHANSVmDeleteObject failure with CHANS_VM_ERR_LOAD_STRING_CONST (-945). The target preserves a deletion failure and only returns -945 when deletion succeeded but the constant index/payload is invalid. A scoped loadResult and normal conditional merge now preserve those paths. No headers, linking flags, symbols, splits, data, or assembly changed. ## Target evidence independently checked CHANSVmStep-relative offsets: +0x9fc calls DeleteObject; +0xa04 branches directly to +0xa64 on nonzero return; +0xa64 preserves r3. Invalid string checks at +0xa24/+0xa38 alone select -945 at +0xa3c. Source-extracted host C tests passed six cases (missing operand, deletion failure with valid/invalid index, invalid index, null payload, success). This is a stubbed behavior harness, not Wii runtime execution. ## Fresh rebased validation on d725e023 - CHANSVm decompiled/fuzzy 99.364426% → 99.383840%; Step 96.466080% → 96.673584%. - Step instruction counts 1253/1253; differing positions 314 → 297. Still non-exact. - Exact functions 221/233, exact code 37608/53564 and exact data 6904/6904 unchanged. No function/unit regressions. - All 1027 allocated native objects audited: only CHANSVm .text changed, size 53564 unchanged; all 1396 text relocations unchanged; all data unchanged. - Pool 125/125 identical. Literal audit:233 functions,40 arguments,zero candidates/errors/skips. - Full all_source/progress/report/DOL check passed; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. - Tests workflow8/literal36/jump-table27/pool8 passed; main and leaf worktree checks pass. - Remote tree20f36c118adf919936736481b44abad1fe24de36 equals tested local tree. No register/volatile forcing, fabricated padding, uninitialized values, retail assembly transplant or score redefinition. Twelve CHANSVm functions remain non-exact. Left for review; no merge performed. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Fix `CHANSVmStep` to preserve accumulator deletion errors in `LOAD_STRING_CONST` > The `LOAD_STRING_CONST` path in [CHANSVm.c](https://github.com/coah80/wii-ipl/pull/963/files#diff-fcd94241dcc82f12e50e6a224211f94b32d8c83c08ab0880c20261cea99b4f75) used a shared goto flow that overwrote the error from `CHANSVmDeleteObject`. The step now stores that deletion result in a local error variable, validates the constant index and string payload only after deletion succeeds, and returns the preserved deletion error when deletion fails. Also adds a validation report in [CHANSVm.allhands-load-constant-attempts.md](https://github.com/coah80/wii-ipl/pull/963/files#diff-6d864a765c570c536a150498477bdfd748f6b2472b5da0a9b4a3f3fda2f2d1df) covering binary-diff and harness results. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 8cd2f7f.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 21:35:30 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.