runtime: distinguish copy-on-write pages in memory queries #197

Merged
Vonsek merged 1 commit from upstream-pr/200 into main 2026-11-21 18:22:15 +00:00
Vonsek commented 2026-11-21 18:20:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T18:20:16Z.


Change

Add a two-page copy-on-write experiment to the Windows desktop_memory_query test. It creates a writable view and a copy view of the same pagefile-backed section. It checks mapping type, working-set sharing and which writes are visible in each view.

Verification

Commit 5c661fa on d1f7c33, Windows x64 build 26200, MSVC 19.44.35230, Debug. Page size was 4,096 bytes.

. ./tools/dev.ps1
cmake --preset dev
cmake --build --preset dev --target memory_query_check era_query_check
ctest --preset dev --no-tests=error -R '^(desktop_memory_query|era_query_.*)$' -V
ctest --preset dev --no-tests=error -R '^desktop_memory_query$' --repeat until-fail:20

All five selected cases passed with zero skips. The standalone repeat passed twenty consecutive times. Before the private write, the copy view showed two resident shared pages. After the write, both views still reported MEM_MAPPED. The working-set query identified the modified page in the copy view as private. The adjacent page and both pages in the writable view remained shared. The marker on the private page stayed isolated. On the adjacent page a write to the shared view appeared in the copy.

For the negative control I initially opened the second view with FILE_MAP_WRITE and ran ctest --preset dev --no-tests=error -R '^desktop_memory_query$' -V. The assertion failed as expected with Mapped page 0: resident=1 shared=1 expected_shared=0. Replacing that flag with FILE_MAP_COPY produced the result above.

Evidence and follow-up

Original MIT-licensed C++ fixture. Both views belong to the test process and use anonymous pagefile backing. Each working-set observation locks the two requested pages, checks the returned validity bit for each and then interprets its sharing bit. This measures desktop Windows copy-on-write behavior. Windows memory query documentation

This contribution was AI-assisted.

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 the Windows memory query experiment in docs/experiments.md.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532665747 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/200). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T18:20:16Z. --- ## Change Add a two-page copy-on-write experiment to the Windows `desktop_memory_query` test. It creates a writable view and a copy view of the same pagefile-backed section. It checks mapping type, working-set sharing and which writes are visible in each view. ## Verification Commit `5c661fa` on `d1f7c33`, Windows x64 build 26200, MSVC 19.44.35230, Debug. Page size was 4,096 bytes. ```powershell . ./tools/dev.ps1 cmake --preset dev cmake --build --preset dev --target memory_query_check era_query_check ctest --preset dev --no-tests=error -R '^(desktop_memory_query|era_query_.*)$' -V ctest --preset dev --no-tests=error -R '^desktop_memory_query$' --repeat until-fail:20 ``` All five selected cases passed with zero skips. The standalone repeat passed twenty consecutive times. Before the private write, the copy view showed two resident shared pages. After the write, both views still reported `MEM_MAPPED`. The working-set query identified the modified page in the copy view as private. The adjacent page and both pages in the writable view remained shared. The marker on the private page stayed isolated. On the adjacent page a write to the shared view appeared in the copy. For the negative control I initially opened the second view with `FILE_MAP_WRITE` and ran `ctest --preset dev --no-tests=error -R '^desktop_memory_query$' -V`. The assertion failed as expected with `Mapped page 0: resident=1 shared=1 expected_shared=0`. Replacing that flag with `FILE_MAP_COPY` produced the result above. ## Evidence and follow-up Original MIT-licensed C++ fixture. Both views belong to the test process and use anonymous pagefile backing. Each working-set observation locks the two requested pages, checks the returned validity bit for each and then interprets its sharing bit. This measures desktop Windows copy-on-write behavior. [Windows memory query documentation](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualqueryex#remarks) This contribution was AI-assisted. ## 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 the Windows memory query experiment in `docs/experiments.md`. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:41:47 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T18:20:34Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T18:22:11.869124Z 5c661fa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067183506 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/200#issuecomment-7067183506). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T18:20:34Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5c661fae0a0b7e0c4c8c13c7dc79fd5245ba5b1b","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T18:22:11.869124Z">2026-11-21T18:22:11.869124Z</relative-time> | `5c661fa` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
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!197
No description provided.