runtime: check every field of an ERA attribute word #1744

Merged
Asimmimx merged 1 commit from upstream-pr/1751 into main 2026-11-24 18:57:23 +00:00
Asimmimx commented 2026-11-24 18:07:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T18:07:22Z.


Refs #1149.

Change

src/era_heap.cpp decode() splits an attribute word with the public ERA layout: objectType:14, pageSize:2, allocatorId:8, alignment:5, memoryType:4 and reserved:31. era_heap_check read it only through the two recorded words (0x05e50000 and 0xa8004000). Both leave the object type and the reserved bits at 0.

I probed decode with 9 single-point mutants:

Mutant Existing 8 scenarios With decode_fields
object type masked to 12 bits survived killed
object type masked to 15 bits killed killed
page size from bit 15 killed killed
allocator masked to 7 bits killed killed
alignment from bit 23 killed killed
alignment masked to 4 bits killed killed
memory type masked to 3 bits killed killed
reserved taken from bit 32 survived killed
reserved taken from bit 34 killed killed

The new decode_fields scenario reads:

  • each field at its widest value alone (0x3fff, 3, 0xff, 0x1f, 0xf, 0x7fffffff);
  • the all-ones word;
  • one word with a distinct value in every field (0x2a5c, 2, 0xb7, 0x13, 9, 0x5a5a5a5).

A mismatch prints the decoded fields. era_heap_decode_fields_control expects a 13-bit object type and is registered with WILL_FAIL. The new row in the era_heap_* table of docs/experiments.md describes both.

The header and decode are not changed.

Results

Commit a992dbaa on origin/main. Windows 11 Pro 26300.9974, MSVC from Visual Studio, dev preset (Debug):

ctest --preset dev --no-tests=error -R '^era_heap_'
100% tests passed, 0 tests failed out of 10

The 10 tests are the eight existing scenarios, era_heap_decode_fields and the WILL_FAIL control, with no skips. Each mutant above was applied to src/era_heap.cpp alone, rebuilt and reverted; the probe script is not committed. docs_links_check.py passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588294906 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1751). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T18:07:22Z. --- Refs #1149. ## Change `src/era_heap.cpp` `decode()` splits an attribute word with the public ERA layout: objectType:14, pageSize:2, allocatorId:8, alignment:5, memoryType:4 and reserved:31. `era_heap_check` read it only through the two recorded words (`0x05e50000` and `0xa8004000`). Both leave the object type and the reserved bits at 0. I probed `decode` with 9 single-point mutants: | Mutant | Existing 8 scenarios | With `decode_fields` | |---|---|---| | object type masked to 12 bits | **survived** | killed | | object type masked to 15 bits | killed | killed | | page size from bit 15 | killed | killed | | allocator masked to 7 bits | killed | killed | | alignment from bit 23 | killed | killed | | alignment masked to 4 bits | killed | killed | | memory type masked to 3 bits | killed | killed | | reserved taken from bit 32 | **survived** | killed | | reserved taken from bit 34 | killed | killed | The new `decode_fields` scenario reads: - each field at its widest value alone (`0x3fff`, 3, `0xff`, `0x1f`, `0xf`, `0x7fffffff`); - the all-ones word; - one word with a distinct value in every field (`0x2a5c`, 2, `0xb7`, `0x13`, 9, `0x5a5a5a5`). A mismatch prints the decoded fields. `era_heap_decode_fields_control` expects a 13-bit object type and is registered with `WILL_FAIL`. The new row in the `era_heap_*` table of `docs/experiments.md` describes both. The header and `decode` are not changed. ## Results Commit `a992dbaa` on `origin/main`. Windows 11 Pro 26300.9974, MSVC from Visual Studio, `dev` preset (Debug): ``` ctest --preset dev --no-tests=error -R '^era_heap_' 100% tests passed, 0 tests failed out of 10 ``` The 10 tests are the eight existing scenarios, `era_heap_decode_fields` and the `WILL_FAIL` control, with no skips. Each mutant above was applied to `src/era_heap.cpp` alone, rebuilt and reverted; the probe script is not committed. `docs_links_check.py` passes. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 19:01:18 +00:00
tedin7 commented 2026-11-24 19:01:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:56:23Z.

Review: COMMENTED


Reviewed at commit a992dbaaf79d7414e97f572dc441852e5f4cc239 (CMakeLists.txt, docs/experiments.md, tests/era_heap_check.cpp).

Code Review

  • tests/era_heap_check.cpp adds decode_field_checks(bool narrow_object_type) exercising every bit field of era_heap::decode() (objectType:14, pageSize:2, allocatorId:8, alignment:5, memoryType:4, reserved:31) individually at max width, all-ones, and with distinct mixed values, plus the WILL_FAIL negative control (narrow_object_type=true masking want.object_type &= 0x1fff).
  • CMakeLists.txt touches only era_heap_check test registration (era_heap_decode_fields and era_heap_decode_fields_control with WILL_FAIL TRUE).
  • docs/experiments.md documents the new scenario and negative control cleanly.
  • Clean-room verified; 0 P1 / 0 P2 findings.

Verification

  • Linux:
    • git diff --check origin/main...HEAD: pass
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: pass (Checked 17 Markdown files and 365 links.)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (Checked 1298 tracked source, script and build/CI files: no bidirectional controls.)
  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, cmake --build --preset dev --target era_heap_check, ctest --preset dev -R '^era_heap_' --parallel 6 --no-tests=error --output-on-failure): 10/10 passed (0.14s, including era_heap_decode_fields 0.01s and era_heap_decode_fields_control 0.01s)
    • Release /O2 (--preset release, cmake --build --preset release --target era_heap_check, ctest --preset release -R '^era_heap_' --parallel 6 --no-tests=error --output-on-failure): 10/10 passed (0.14s, including era_heap_decode_fields 0.02s and era_heap_decode_fields_control 0.01s)
  • Local mutation check on Win2025 (reverted after verification):
    • Narrowing object_type mask (0x3fff -> 0xfff) and shifting reserved (>> 33 -> >> 32) in src/era_heap.cpp: era_heap_decode_fields failed (0/1 passed, reporting FAIL: decode object type, memory type, reserved, all ones, and mixed).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045430229 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1751#pullrequestreview-6045430229). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:56:23Z. **Review:** COMMENTED --- Reviewed at commit `a992dbaaf79d7414e97f572dc441852e5f4cc239` (`CMakeLists.txt`, `docs/experiments.md`, `tests/era_heap_check.cpp`). ### Code Review - `tests/era_heap_check.cpp` adds `decode_field_checks(bool narrow_object_type)` exercising every bit field of `era_heap::decode()` (`objectType:14`, `pageSize:2`, `allocatorId:8`, `alignment:5`, `memoryType:4`, `reserved:31`) individually at max width, all-ones, and with distinct mixed values, plus the `WILL_FAIL` negative control (`narrow_object_type=true` masking `want.object_type &= 0x1fff`). - `CMakeLists.txt` touches only `era_heap_check` test registration (`era_heap_decode_fields` and `era_heap_decode_fields_control` with `WILL_FAIL TRUE`). - `docs/experiments.md` documents the new scenario and negative control cleanly. - Clean-room verified; 0 P1 / 0 P2 findings. ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: pass - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: pass (`Checked 17 Markdown files and 365 links.`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: pass (`Checked 1298 tracked source, script and build/CI files: no bidirectional controls.`) - **Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `cmake --build --preset dev --target era_heap_check`, `ctest --preset dev -R '^era_heap_' --parallel 6 --no-tests=error --output-on-failure`): **10/10 passed** (`0.14s`, including `era_heap_decode_fields` `0.01s` and `era_heap_decode_fields_control` `0.01s`) - Release `/O2` (`--preset release`, `cmake --build --preset release --target era_heap_check`, `ctest --preset release -R '^era_heap_' --parallel 6 --no-tests=error --output-on-failure`): **10/10 passed** (`0.14s`, including `era_heap_decode_fields` `0.02s` and `era_heap_decode_fields_control` `0.01s`) - **Local mutation check on Win2025** (reverted after verification): - Narrowing `object_type` mask (`0x3fff` -> `0xfff`) and shifting `reserved` (`>> 33` -> `>> 32`) in `src/era_heap.cpp`: `era_heap_decode_fields` failed (`0/1 passed`, reporting `FAIL: decode object type`, `memory type`, `reserved`, `all ones`, and `mixed`). AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-24 20:01:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T19:06:47Z.


Both "survived" mutants reproduce exactly as the PR body says

At a992dbaa, MSVC 14.44.35207, Windows 11 build 26300.9974. The two new tests register and pass:

cmake --preset dev
cmake --build --preset dev --target era_heap_check
ctest --preset dev -R '^era_heap_'
Test  #12: era_heap_decode_fields .......... Passed
Test  #13: era_heap_decode_fields_control .. Passed
100% tests passed, 0 tests failed out of 10

I then reproduced the two mutants the description lists as survived before this change, rebuilding era_heap_check.exe
each time (binary timestamp checked) and running the eight old scenarios and the new one separately:

mutant old 8 scenarios era_heap_decode_fields
attributes & 0x3fff → attributes & 0xfff green red
attributes >> 33 → attributes >> 32 green red

That is the claim in the description, confirmed independently: the old fixtures cannot see either change, and the new
scenario kills both. Reverted, all ten pass again.

The negative control is real

era_heap_decode_fields_control is registered with WILL_FAIL TRUE and expects a 13-bit object type; the widest object
type in the new scenario makes it fail. Worth keeping, because it is the one test that would still pass if the fixture
stopped producing wide words.

One small thing

The first ctest --preset dev -N I ran right after checking the branch out did not list either new test; a second
cmake --preset dev made them appear. That was my own sequence (configure ran against the pre-checkout CMakeLists.txt
in the same command), not a property of the change — but it cost me two minutes, so the reproduction in the body might
mention that the configure has to run after the checkout.

Verdict

Reviewed a992dbaa. The new scenario reads every field at its widest value and one word with a distinct value per field,
the two mutants that used to survive are dead, and the WILL_FAIL control is the right shape. No objections.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141617731 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1751#issuecomment-7141617731). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T19:06:47Z. --- ## Both "survived" mutants reproduce exactly as the PR body says At `a992dbaa`, MSVC 14.44.35207, Windows 11 build 26300.9974. The two new tests register and pass: ```powershell cmake --preset dev cmake --build --preset dev --target era_heap_check ctest --preset dev -R '^era_heap_' ``` ```text Test #12: era_heap_decode_fields .......... Passed Test #13: era_heap_decode_fields_control .. Passed 100% tests passed, 0 tests failed out of 10 ``` I then reproduced the two mutants the description lists as *survived before this change*, rebuilding `era_heap_check.exe` each time (binary timestamp checked) and running the eight old scenarios and the new one separately: | mutant | old 8 scenarios | `era_heap_decode_fields` | |---|---|---| | `attributes & 0x3fff` → `attributes & 0xfff` | **green** | **red** | | `attributes >> 33` → `attributes >> 32` | **green** | **red** | That is the claim in the description, confirmed independently: the old fixtures cannot see either change, and the new scenario kills both. Reverted, all ten pass again. ## The negative control is real `era_heap_decode_fields_control` is registered with `WILL_FAIL TRUE` and expects a 13-bit object type; the widest object type in the new scenario makes it fail. Worth keeping, because it is the one test that would still pass if the fixture stopped producing wide words. ## One small thing The first `ctest --preset dev -N` I ran right after checking the branch out did not list either new test; a second `cmake --preset dev` made them appear. That was my own sequence (configure ran against the pre-checkout `CMakeLists.txt` in the same command), not a property of the change — but it cost me two minutes, so the reproduction in the body might mention that the configure has to run after the checkout. ## Verdict Reviewed `a992dbaa`. The new scenario reads every field at its widest value and one word with a distinct value per field, the two mutants that used to survive are dead, and the `WILL_FAIL` control is the right shape. No objections. ## Notes - AI-assisted review.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1744
No description provided.