runtime: verify local_log env_on, logf, and page probes without GPU #1470

Merged
Ammmae0x merged 1 commit from upstream-pr/1477 into main 2026-11-24 13:07:34 +00:00
Ammmae0x commented 2026-11-24 12:34:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T12:34:28Z.


Change

Add a device-free Win32/SEH check (tests/startup_local_log_check.cpp) for src/startup_stubs/local_log.h without altering the header itself, registered as startup_local_log and negative control startup_local_log_guard_drop_control (WILL_FAIL TRUE) in CMakeLists.txt and documented in docs/startup-runtime.md. Refs #1149.

Covered x2w_local helpers and behaviors:

  • env_on: unset and non-"1" values ("", "0", "2", "true", "on") return false; "1" returns true; GetLastError() is preserved across both absent and present lookups.
  • first_calls: exact 1..limit gating, limit <= 0 rejection, and 4-thread concurrent InterlockedIncrement exactness.
  • logf: GetLastError() preservation with X2W_TRAP_LOG unset or set, CRLF append behavior, and 1533-byte payload truncation (1536 buffer minus \r\n and NUL).
  • probe_readable: rejection of null, < 0x10000, > 0x00007FFFFFFEFFFF, and zero-byte lengths; multi-page and unaligned reads; clean prefix truncation before PAGE_NOACCESS and MEM_RESERVE; and PAGE_GUARD stop plus guard-bit re-arming verified via VirtualQuery and a second probe.
  • readable / writable (accessible): PAGE_READONLY, PAGE_READWRITE, PAGE_WRITECOPY, PAGE_NOACCESS, PAGE_GUARD, MEM_RESERVE, and cross-page boundary checks while keeping PAGE_GUARD armed.
  • Negative control (--mutate guard-drop): expects PAGE_GUARD to be dropped rather than re-armed and fails 1 of 58 checks (WILL_FAIL TRUE).

Verification

Verified on commit 3ed5928a (rebased cleanly onto upstream/main 2ae8a9e4) in both dev (Debug) and release (/O2) presets with zero compiler errors or warnings:

  • Test list check:
    & .\tools\dev.ps1; ctest --preset dev -N -> 942 total tests (startup_local_log, startup_local_log_guard_drop_control present).
  • dev build and targeted tests:
    cmake --build --preset dev --target startup_local_log_check
    ctest --preset dev --no-tests=error -R "^startup_local_log(_guard_drop_control)?$" -V
    -> 2 passed, 0 failed, 0 skipped (startup_local_log: PASS (63 cases); startup_local_log_guard_drop_control: 1 of 58 FAILED, passed under WILL_FAIL TRUE).
  • release (/O2) build and targeted tests:
    cmake --build --preset release --target startup_local_log_check
    ctest --preset release --no-tests=error -R "^startup_local_log(_guard_drop_control)?$" -V
    -> 2 passed, 0 failed, 0 skipped (startup_local_log: PASS (63 cases); startup_local_log_guard_drop_control: 1 of 58 FAILED, passed under WILL_FAIL TRUE).
  • Repository invariant checks:
    .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py -> form coverage checks passed (exit 0).
    .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py -> Checked 16 Markdown files and 332 links. (exit 0).
    .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py -> Checked 1214 tracked source, script and build/CI files: no bidirectional controls. (exit 0).

Evidence and follow-up

  • Fixture source: tests/startup_local_log_check.cpp is an original C++ Win32/SEH test written for this repository using synthetic VirtualAlloc, CreateFileMappingW/MapViewOfFile, and temporary X2W_TRAP_LOG files.
  • Follow-up: addresses one untested src/startup_stubs/ helper header under #1149; the remaining broader CI and stand-in checks in #1149 stay open.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581896024 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1477). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-24T12:34:28Z. --- ## Change Add a device-free Win32/SEH check (`tests/startup_local_log_check.cpp`) for `src/startup_stubs/local_log.h` without altering the header itself, registered as `startup_local_log` and negative control `startup_local_log_guard_drop_control` (`WILL_FAIL TRUE`) in `CMakeLists.txt` and documented in `docs/startup-runtime.md`. Refs #1149. Covered `x2w_local` helpers and behaviors: - `env_on`: unset and non-`"1"` values (`""`, `"0"`, `"2"`, `"true"`, `"on"`) return `false`; `"1"` returns `true`; `GetLastError()` is preserved across both absent and present lookups. - `first_calls`: exact `1..limit` gating, `limit <= 0` rejection, and 4-thread concurrent `InterlockedIncrement` exactness. - `logf`: `GetLastError()` preservation with `X2W_TRAP_LOG` unset or set, CRLF append behavior, and 1533-byte payload truncation (`1536` buffer minus `\r\n` and `NUL`). - `probe_readable`: rejection of null, `< 0x10000`, `> 0x00007FFFFFFEFFFF`, and zero-byte lengths; multi-page and unaligned reads; clean prefix truncation before `PAGE_NOACCESS` and `MEM_RESERVE`; and `PAGE_GUARD` stop plus guard-bit re-arming verified via `VirtualQuery` and a second probe. - `readable` / `writable` (`accessible`): `PAGE_READONLY`, `PAGE_READWRITE`, `PAGE_WRITECOPY`, `PAGE_NOACCESS`, `PAGE_GUARD`, `MEM_RESERVE`, and cross-page boundary checks while keeping `PAGE_GUARD` armed. - Negative control (`--mutate guard-drop`): expects `PAGE_GUARD` to be dropped rather than re-armed and fails 1 of 58 checks (`WILL_FAIL TRUE`). ## Verification Verified on commit `3ed5928a` (rebased cleanly onto `upstream/main` `2ae8a9e4`) in both `dev` (Debug) and `release` (`/O2`) presets with zero compiler errors or warnings: - Test list check: `& .\tools\dev.ps1; ctest --preset dev -N` -> `942` total tests (`startup_local_log`, `startup_local_log_guard_drop_control` present). - `dev` build and targeted tests: `cmake --build --preset dev --target startup_local_log_check` `ctest --preset dev --no-tests=error -R "^startup_local_log(_guard_drop_control)?$" -V` -> `2 passed, 0 failed, 0 skipped` (`startup_local_log`: `PASS (63 cases)`; `startup_local_log_guard_drop_control`: `1 of 58 FAILED`, passed under `WILL_FAIL TRUE`). - `release` (`/O2`) build and targeted tests: `cmake --build --preset release --target startup_local_log_check` `ctest --preset release --no-tests=error -R "^startup_local_log(_guard_drop_control)?$" -V` -> `2 passed, 0 failed, 0 skipped` (`startup_local_log`: `PASS (63 cases)`; `startup_local_log_guard_drop_control`: `1 of 58 FAILED`, passed under `WILL_FAIL TRUE`). - Repository invariant checks: `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0). `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py` -> `Checked 16 Markdown files and 332 links.` (exit 0). `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py` -> `Checked 1214 tracked source, script and build/CI files: no bidirectional controls.` (exit 0). ## Evidence and follow-up - Fixture source: `tests/startup_local_log_check.cpp` is an original C++ Win32/SEH test written for this repository using synthetic `VirtualAlloc`, `CreateFileMappingW`/`MapViewOfFile`, and temporary `X2W_TRAP_LOG` files. - Follow-up: addresses one untested `src/startup_stubs/` helper header under #1149; the remaining broader CI and stand-in checks in #1149 stay open. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
tedin7 commented 2026-11-24 13:00:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:39:48Z.

Review: COMMENTED


Reviewed tests/startup_local_log_check.cpp, CMakeLists.txt, and docs/startup-runtime.md at 3ed5928a0f7566820c4044b0fbca5d6c53d45fb5 against src/startup_stubs/local_log.h (header itself is unchanged).

Audit notes

  • Coverage & correctness:
    • env_on: covers unset, non-"1" values ("", "0", "2", "true", "on"), and "1", verifying GetLastError() preservation in all cases and restoring the test env var afterward.
    • first_calls: covers 1..limit, limit <= 0, and 4-thread concurrent InterlockedIncrement exactness (400 increments, 10 accepted).
    • logf: redirects STD_ERROR_HANDLE to NUL and restores it, preserves/restores X2W_TRAP_LOG, verifies GetLastError() preservation (unset and set), CRLF append, and 1533-byte payload truncation (1536 buffer minus \r\n and NUL), cleaning up the temp log file.
    • probe_readable & readable/writable (accessible): covers invalid pointer bounds (0, < 0x10000, > 0x00007FFFFFFEFFFF) and zero-byte lengths, multi-page/unaligned reads, PAGE_READONLY and PAGE_WRITECOPY (CreateFileMappingW/MapViewOfFile(FILE_MAP_COPY)), PAGE_NOACCESS and MEM_RESERVE prefix truncation, and PAGE_GUARD stop + re-arming verified via VirtualQuery and a second probe.
  • Negative control: startup_local_log_guard_drop_control (--mutate guard-drop, WILL_FAIL TRUE) expects PAGE_GUARD to be cleared and fails as expected.
  • Hygiene: title-neutral, no leaked handles/allocations/env vars.

Verification

Linux (at 3ed5928a0f7566820c4044b0fbca5d6c53d45fb5):

  • git diff --check origin/main..HEAD: clean (exit 0).
  • python3 tests/docs_links_check.py: Checked 16 Markdown files and 332 links. (exit 0).
  • python3 tests/bidi_controls_check.py: Checked 1214 tracked source, script and build/CI files: no bidirectional controls. (exit 0).

Windows Server 2025 (Build 26100, MSVC 14.44.35207, commit 3ed5928a0f7566820c4044b0fbca5d6c53d45fb5):

  • Debug (--preset dev):
    • cmake --build --preset dev --target startup_local_log_check -- -j 6: built cleanly (3.88s).
    • ctest --preset dev -R '^startup_local_log(_guard_drop_control)?$' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (startup_local_log 0.02s, startup_local_log_guard_drop_control 0.01s).
  • Release /O2 (--preset release):
    • cmake --build --preset release --target startup_local_log_check -- -j 6: built cleanly (1.19s).
    • ctest --preset release -R '^startup_local_log(_guard_drop_control)?$' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (startup_local_log 0.02s, startup_local_log_guard_drop_control 0.01s).

Looks ready to merge.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039340537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1477#pullrequestreview-6039340537). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T12:39:48Z. **Review:** COMMENTED --- Reviewed `tests/startup_local_log_check.cpp`, `CMakeLists.txt`, and `docs/startup-runtime.md` at `3ed5928a0f7566820c4044b0fbca5d6c53d45fb5` against `src/startup_stubs/local_log.h` (header itself is unchanged). ### Audit notes - **Coverage & correctness**: - `env_on`: covers unset, non-`"1"` values (`""`, `"0"`, `"2"`, `"true"`, `"on"`), and `"1"`, verifying `GetLastError()` preservation in all cases and restoring the test env var afterward. - `first_calls`: covers `1..limit`, `limit <= 0`, and 4-thread concurrent `InterlockedIncrement` exactness (`400` increments, `10` accepted). - `logf`: redirects `STD_ERROR_HANDLE` to `NUL` and restores it, preserves/restores `X2W_TRAP_LOG`, verifies `GetLastError()` preservation (unset and set), CRLF append, and 1533-byte payload truncation (`1536` buffer minus `\r\n` and `NUL`), cleaning up the temp log file. - `probe_readable` & `readable`/`writable` (`accessible`): covers invalid pointer bounds (`0`, `< 0x10000`, `> 0x00007FFFFFFEFFFF`) and zero-byte lengths, multi-page/unaligned reads, `PAGE_READONLY` and `PAGE_WRITECOPY` (`CreateFileMappingW`/`MapViewOfFile(FILE_MAP_COPY)`), `PAGE_NOACCESS` and `MEM_RESERVE` prefix truncation, and `PAGE_GUARD` stop + re-arming verified via `VirtualQuery` and a second probe. - **Negative control**: `startup_local_log_guard_drop_control` (`--mutate guard-drop`, `WILL_FAIL TRUE`) expects `PAGE_GUARD` to be cleared and fails as expected. - **Hygiene**: title-neutral, no leaked handles/allocations/env vars. ### Verification **Linux** (at `3ed5928a0f7566820c4044b0fbca5d6c53d45fb5`): - `git diff --check origin/main..HEAD`: clean (exit 0). - `python3 tests/docs_links_check.py`: `Checked 16 Markdown files and 332 links.` (exit 0). - `python3 tests/bidi_controls_check.py`: `Checked 1214 tracked source, script and build/CI files: no bidirectional controls.` (exit 0). **Windows Server 2025** (Build 26100, MSVC 14.44.35207, commit `3ed5928a0f7566820c4044b0fbca5d6c53d45fb5`): - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target startup_local_log_check -- -j 6`: built cleanly (`3.88s`). - `ctest --preset dev -R '^startup_local_log(_guard_drop_control)?$' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** (`startup_local_log` `0.02s`, `startup_local_log_guard_drop_control` `0.01s`). - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target startup_local_log_check -- -j 6`: built cleanly (`1.19s`). - `ctest --preset release -R '^startup_local_log(_guard_drop_control)?$' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** (`startup_local_log` `0.02s`, `startup_local_log_guard_drop_control` `0.01s`). Looks ready to merge.
upstream-sync closed this pull request 2026-11-24 14:02:49 +00:00
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!1470
No description provided.