runtime: read the view heap trap log with write sharing #2004

Closed
alvaroolt wants to merge 1 commit from upstream-pr/2011 into main
alvaroolt commented 2026-11-24 23:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alvaroolt on 2026-11-24T23:02:19Z.


Change

startup_view_heap_hardware fails on current main on any adapter that refuses the full 1,245,184-descriptor shader-visible view heap, although the stand-in logs the shortcut correctly:

x2w-d3d12 Device::CreateDescriptorHeap: shortcut - title asked for 1245184 shader-visible view descriptors, this driver accepts 1000000; the rest stay in title memory
shortcut logged -1 times, expected 1

The -1 means the test could not open the log. count_shortcut_lines reads X2W_TRAP_LOG with _wfopen_s, which denies write sharing. Since #1757, append_log in src/startup_stubs/trap.h keeps the log open with FILE_APPEND_DATA while the module is loaded. Its comment says it shares read/write/delete "so readers and cleanup still work". The reader's open therefore fails with ERROR_SHARING_VIOLATION. WARP accepts the full request and skips (77), so CI does not run this path.

This change reads the log with CreateFileW and FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, as the other in-process trap-log readers do (startup_chad_check.cpp, startup_local_log_check.cpp, startup_storage_*). A failed open is now reported with its error code instead of as a count of -1. The stand-in is unchanged, and the test still requires exactly one shortcut line.

Follow-up to #1757 (test from c74485f5 / ab1ea74a). No issue.

Verification

Environment: Windows 11 10.0.26300, MSVC 14.52, Windows SDK 10.0.26100. NVIDIA GeForce RTX 5080 (10de:2c02), driver 621.24 (32.0.16.2124). AMD Radeon(TM) Graphics iGPU (1002:13c0), driver 32.0.11034.2. Microsoft WARP. D3D12 debug layer unavailable (Graphics Tools not installed).

Before, at 150c625a (main):

ctest --preset dev --no-tests=error -R '^startup_view_heap' -V
# startup_view_heap_hardware (RTX 5080): Failed: "shortcut logged -1 times, expected 1"
# startup_view_heap_warp: Skipped (77): "adapter accepts 1245184 descriptors directly"

After, on 5b7947e5 plus this change (5de9b999):

Test Adapter Result
startup_view_heap_hardware RTX 5080 Passed: oversized heap accepted; shortcut logged once; 1245184 requested
startup_view_heap_hardware with XBOX2WINDOWS_ADAPTER=Radeon Radeon iGPU Skipped (77): accepts 1,245,184 directly
startup_view_heap_warp WARP Skipped (77): accepts 1,245,184 directly

Only the RTX 5080 exercises the shortcut on this machine, so this is the only adapter that verifies the fix.

Full suites, run on 889cd3f4 plus this change:

ctest --preset dev --no-tests=error -j8       # 1258 tests: 1230 passed, 0 failed, 28 capability skips
cmake --preset release; cmake --build --preset release
ctest --preset release --no-tests=error -j8   # 1258 tests: 1230 passed, 0 failed, 28 capability skips
python -B tools/run_checks_parallel.py <the 72 checks of the Linux Python job>   # all 72 checks passed

After the rebase onto 5b7947e5 (which changes only CMakeLists.txt among the files involved), the dev rebuild, ctest --preset dev --no-tests=error -j8 -R '^startup_' (306 tests) and the 72 Python checks had no failures.

Negative controls (RTX 5080, both reverted afterwards):

  • Reader opened with FILE_SHARE_READ only, the sharing _wfopen_s uses: the test fails with cannot read the trap log: error 32 (ERROR_SHARING_VIOLATION). This confirms the cause of the -1.
  • Stand-in mutated to log the shortcut twice (first_calls(shortcuts, 2) in d3d12_xs_device.cpp): the test fails with shortcut logged 2 times, expected 1. The once-only check still works.

Evidence and follow-up

No new fixture or input. No README or docs change: no command or capability changes.

This change was AI-assisted (Claude Code); I reviewed the diff and the test results.

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. (No change needed.)
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593160230 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2011). Originally posted by [alvaroolt](https://github.com/alvaroolt) on 2026-11-24T23:02:19Z. --- ## Change `startup_view_heap_hardware` fails on current `main` on any adapter that refuses the full 1,245,184-descriptor shader-visible view heap, although the stand-in logs the shortcut correctly: ```text x2w-d3d12 Device::CreateDescriptorHeap: shortcut - title asked for 1245184 shader-visible view descriptors, this driver accepts 1000000; the rest stay in title memory shortcut logged -1 times, expected 1 ``` The -1 means the test could not open the log. `count_shortcut_lines` reads `X2W_TRAP_LOG` with `_wfopen_s`, which denies write sharing. Since #1757, `append_log` in `src/startup_stubs/trap.h` keeps the log open with `FILE_APPEND_DATA` while the module is loaded. Its comment says it shares read/write/delete "so readers and cleanup still work". The reader's open therefore fails with `ERROR_SHARING_VIOLATION`. WARP accepts the full request and skips (77), so CI does not run this path. This change reads the log with `CreateFileW` and `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`, as the other in-process trap-log readers do (`startup_chad_check.cpp`, `startup_local_log_check.cpp`, `startup_storage_*`). A failed open is now reported with its error code instead of as a count of -1. The stand-in is unchanged, and the test still requires exactly one shortcut line. Follow-up to #1757 (test from c74485f5 / ab1ea74a). No issue. ## Verification Environment: Windows 11 10.0.26300, MSVC 14.52, Windows SDK 10.0.26100. NVIDIA GeForce RTX 5080 (10de:2c02), driver 621.24 (32.0.16.2124). AMD Radeon(TM) Graphics iGPU (1002:13c0), driver 32.0.11034.2. Microsoft WARP. D3D12 debug layer unavailable (Graphics Tools not installed). Before, at 150c625a (`main`): ```powershell ctest --preset dev --no-tests=error -R '^startup_view_heap' -V # startup_view_heap_hardware (RTX 5080): Failed: "shortcut logged -1 times, expected 1" # startup_view_heap_warp: Skipped (77): "adapter accepts 1245184 descriptors directly" ``` After, on 5b7947e5 plus this change (5de9b999): | Test | Adapter | Result | |---|---|---| | `startup_view_heap_hardware` | RTX 5080 | Passed: `oversized heap accepted; shortcut logged once; 1245184 requested` | | `startup_view_heap_hardware` with `XBOX2WINDOWS_ADAPTER=Radeon` | Radeon iGPU | Skipped (77): accepts 1,245,184 directly | | `startup_view_heap_warp` | WARP | Skipped (77): accepts 1,245,184 directly | Only the RTX 5080 exercises the shortcut on this machine, so this is the only adapter that verifies the fix. Full suites, run on 889cd3f4 plus this change: ```powershell ctest --preset dev --no-tests=error -j8 # 1258 tests: 1230 passed, 0 failed, 28 capability skips cmake --preset release; cmake --build --preset release ctest --preset release --no-tests=error -j8 # 1258 tests: 1230 passed, 0 failed, 28 capability skips python -B tools/run_checks_parallel.py <the 72 checks of the Linux Python job> # all 72 checks passed ``` After the rebase onto 5b7947e5 (which changes only `CMakeLists.txt` among the files involved), the dev rebuild, `ctest --preset dev --no-tests=error -j8 -R '^startup_'` (306 tests) and the 72 Python checks had no failures. **Negative controls** (RTX 5080, both reverted afterwards): - Reader opened with `FILE_SHARE_READ` only, the sharing `_wfopen_s` uses: the test fails with `cannot read the trap log: error 32` (`ERROR_SHARING_VIOLATION`). This confirms the cause of the -1. - Stand-in mutated to log the shortcut twice (`first_calls(shortcuts, 2)` in `d3d12_xs_device.cpp`): the test fails with `shortcut logged 2 times, expected 1`. The once-only check still works. ## Evidence and follow-up No new fixture or input. No README or docs change: no command or capability changes. This change was AI-assisted (Claude Code); I reviewed the diff and the test results. ## 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. (No change needed.) - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-25 00:04:54 +00:00
tedin7 commented 2026-11-25 00:04:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:08:04Z.

Review: COMMENTED


Review of head 5de9b999d8 (comment only, no approval).

Diff: only tests/startup_view_heap_check.cpp (+30/-9). No CMake change. The reader now opens the trap log with CreateFileW and read/write/delete sharing, so it no longer fails with a sharing violation while the stand-in holds the log open for appending. An open failure now reports the Win32 error and fails instead of returning a count. The line splitting and counting logic reads correctly. Clean-room: no third-party code, no game data.

Commands executed locally:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts
  • gh pr checks 2011: Windows build and test pass, Linux Python checks pass, gfx1013 fixtures pass; /O2 job skipping
  • python3 tests/docs_links_check.py: pass (18 files, 388 links)
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • Win2025 (x2w_pipe.py win2025 2011, build 26100, MSVC 14.44.35207, WARP), Debug dev and Release /O2: both build. startup_view_heap_warp returned 77 in both (capability skip, not a pass). WARP accepted the full descriptor request, so the shortcut and the changed log reader did not run.

Mutation check: not done. The changed reader only runs after the adapter refuses the full request, and no adapter available here does, so a mutation (for example dropping FILE_SHARE_WRITE) could not be killed by a run that executes the code.

P1: 0. P2: 0.

Result: no merge from this pass. Merge needs a run where the test actually executes (an adapter that refuses the full request) plus a killed mutation. Happy to re-check on a new head or with such a run.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048848517 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2011#pullrequestreview-6048848517). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:08:04Z. **Review:** COMMENTED --- Review of head 5de9b999d8a71c1aabcea70da0f06e72a452851b (comment only, no approval). Diff: only `tests/startup_view_heap_check.cpp` (+30/-9). No CMake change. The reader now opens the trap log with `CreateFileW` and read/write/delete sharing, so it no longer fails with a sharing violation while the stand-in holds the log open for appending. An open failure now reports the Win32 error and fails instead of returning a count. The line splitting and counting logic reads correctly. Clean-room: no third-party code, no game data. Commands executed locally: - `git merge-tree --write-tree --name-only origin/main HEAD`: clean, no conflicts - `gh pr checks 2011`: Windows build and test pass, Linux Python checks pass, gfx1013 fixtures pass; `/O2` job skipping - `python3 tests/docs_links_check.py`: pass (18 files, 388 links) - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - Win2025 (`x2w_pipe.py win2025 2011`, build 26100, MSVC 14.44.35207, WARP), Debug `dev` and Release `/O2`: both build. `startup_view_heap_warp` returned 77 in both (capability skip, not a pass). WARP accepted the full descriptor request, so the shortcut and the changed log reader did not run. Mutation check: not done. The changed reader only runs after the adapter refuses the full request, and no adapter available here does, so a mutation (for example dropping `FILE_SHARE_WRITE`) could not be killed by a run that executes the code. P1: 0. P2: 0. Result: no merge from this pass. Merge needs a run where the test actually executes (an adapter that refuses the full request) plus a killed mutation. Happy to re-check on a new head or with such a run. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 01:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:30:27Z.


Thanks for reproducing the sharing failure. #2001 landed the same fix using the existing streaming reader with explicit write sharing. I reran the shortcut check on RTX and it passed. WARP skipped because it accepted the full heap. Closing this overlapping patch.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147477682 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2011#issuecomment-7147477682). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T23:30:27Z. --- Thanks for reproducing the sharing failure. #2001 landed the same fix using the existing streaming reader with explicit write sharing. I reran the shortcut check on RTX and it passed. WARP skipped because it accepted the full heap. Closing this overlapping patch.

Pull request closed

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!2004
No description provided.