fix(chans): use the boolean helper's scalar output contract #1050

Merged
coah80 merged 1 commits from agent/bittle/chans-boolean-review into main 2026-10-03 05:15:35 +00:00
coah80 commented 2026-10-03 05:14:49 +00:00 (Migrated from github.com)

Source contract

CHANSVmGetBoolean writes an optional four-byte vmBoolInt, but was declared to receive a 16-byte, eight-aligned CHANSVmObjHdr. Three Step callers cast scalar locals to that fictitious object type; two pass the original stack+0x0c destination, aligned for the scalar but not the object.

Use vmBoolInt* and *ret, make the two receiving locals vmBoolInt, and remove all three casts. Repository source and original-object reference scans find no other callers or shared-header declaration. Original helper's sole output store and all three Step call destinations were checked against the raw DOL. MWCC layout probe confirms object8/16 versus scalar4/4 alignment/size.

Independent verification

Rebased and tested on fc114afd44065fb99f9ff2fe2969f393a504fe03; tree e52b1f3b98.

  • Source-extracted baseline UBSan reproduces misaligned-object access; candidate passes 1,283 typed-output cases, corresponding null-output calls and canaries
  • Cases cover all256 discriminators, integer limits, string lengths, floating zero/infinity/NaN, error and no-write paths
  • Raw DOL checks: 48 nonrelocated helper words, direct callees, three Step destinations and scalar output store at0x8144c664
  • Whole object byte-identical; all1,027 report units and allocated payloads/canonical relocations unchanged
  • Unit222/233 exact,38136/53564 matched code,6904/6904 matched data; no fuzzy gain
  • Pool125/125 identical; literal audit233 functions/40 arguments, no skips/candidates/errors
  • Full43U build/report/DOL passed; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; worktree/diff checks pass

The host harness models object layout and uses an isnan shim; this is not full VM/Wii runtime testing. Details: tools/decomp-assist/CHANSVm-boolean-output-20261003.md. No linking flags or headers changed.

Note

Fix CHANSVmGetBoolean to output a vmBoolInt scalar

  • Changes the CHANSVmGetBoolean output parameter from CHANSVmObjHdr* to vmBoolInt* in CHANSVm.c, so the result is stored directly through a scalar pointer instead of an object-header boolean member
  • Updates CHANSVmStep to use vmBoolInt locals for branch and logical-not results, removing the casts that passed them as CHANSVmObjHdr pointers
  • Adds a technical note in CHANSVm-boolean-output-20261003.md documenting the corrected contract and validation
  • Risk: none — the compiled object remains byte-identical per the build gates in the note

Macroscope summarized 5cc10dc.

## Source contract CHANSVmGetBoolean writes an optional four-byte vmBoolInt, but was declared to receive a 16-byte, eight-aligned CHANSVmObjHdr. Three Step callers cast scalar locals to that fictitious object type; two pass the original stack+0x0c destination, aligned for the scalar but not the object. Use vmBoolInt* and *ret, make the two receiving locals vmBoolInt, and remove all three casts. Repository source and original-object reference scans find no other callers or shared-header declaration. Original helper's sole output store and all three Step call destinations were checked against the raw DOL. MWCC layout probe confirms object8/16 versus scalar4/4 alignment/size. ## Independent verification Rebased and tested on fc114afd44065fb99f9ff2fe2969f393a504fe03; tree e52b1f3b98afa27f63a9cb1c5f3046dfcbfa56e2. - Source-extracted baseline UBSan reproduces misaligned-object access; candidate passes 1,283 typed-output cases, corresponding null-output calls and canaries - Cases cover all256 discriminators, integer limits, string lengths, floating zero/infinity/NaN, error and no-write paths - Raw DOL checks: 48 nonrelocated helper words, direct callees, three Step destinations and scalar output store at0x8144c664 - Whole object byte-identical; all1,027 report units and allocated payloads/canonical relocations unchanged - Unit222/233 exact,38136/53564 matched code,6904/6904 matched data; no fuzzy gain - Pool125/125 identical; literal audit233 functions/40 arguments, no skips/candidates/errors - Full43U build/report/DOL passed; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; worktree/diff checks pass The host harness models object layout and uses an isnan shim; this is not full VM/Wii runtime testing. Details: tools/decomp-assist/CHANSVm-boolean-output-20261003.md. No linking flags or headers changed. <!-- 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 `CHANSVmGetBoolean` to output a `vmBoolInt` scalar > - Changes the `CHANSVmGetBoolean` output parameter from `CHANSVmObjHdr*` to `vmBoolInt*` in [CHANSVm.c](https://github.com/coah80/wii-ipl/pull/1050/files#diff-fcd94241dcc82f12e50e6a224211f94b32d8c83c08ab0880c20261cea99b4f75), so the result is stored directly through a scalar pointer instead of an object-header boolean member > - Updates `CHANSVmStep` to use `vmBoolInt` locals for branch and logical-not results, removing the casts that passed them as `CHANSVmObjHdr` pointers > - Adds a technical note in [CHANSVm-boolean-output-20261003.md](https://github.com/coah80/wii-ipl/pull/1050/files#diff-c61bacfbec145a4d8f17035580784112d4f1914a97667f112bc102f28fbbaa20) documenting the corrected contract and validation > - Risk: none — the compiled object remains byte-identical per the build gates in the note > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 5cc10dc.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 05:15:33 +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.