[removed by author] #322

Merged
thegl0w merged 6 commits from upstream-pr/327 into main 2026-11-22 04:51:41 +00:00
thegl0w commented 2026-11-21 22:17:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thegl0w on 2026-11-21T22:17:01Z.


[removed by author]

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5433008875 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/327). Originally posted by [thegl0w](https://github.com/thegl0w) on 2026-11-21T22:17:01Z. --- [removed by author]
upstream-sync closed this pull request 2026-11-24 06:42:26 +00:00
R0Y00 commented 2026-11-24 06:48:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:45:07Z.


state() first allocates State with throwing new, but the public registry paths are noexcept. In particular, track() calls state() before entering its bad_alloc handler. If that first allocation fails while servicing XMemAlloc, the process terminates instead of following the allocation-failure path. Please make first-use initialization safe for these entry points and keep registry/device destruction out of DLL teardown. A focused failure-path check should demonstrate that a failed first track leaves no partial registration and can be retried.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073753684 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/327#issuecomment-7073753684). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:45:07Z. --- `state()` first allocates `State` with throwing `new`, but the public registry paths are `noexcept`. In particular, `track()` calls `state()` before entering its `bad_alloc` handler. If that first allocation fails while servicing XMemAlloc, the process terminates instead of following the allocation-failure path. Please make first-use initialization safe for these entry points and keep registry/device destruction out of DLL teardown. A focused failure-path check should demonstrate that a failed first track leaves no partial registration and can be retried.
R0Y00 commented 2026-11-24 06:48:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:49:58Z.


For this PR, keep the registry private to the module that owns it (option c) and preserve the four XMem exports. The direct-linked fixture can claim attach/lookup behavior within that module. A D3D12 client in another DLL needs a single shared registry and a two-DLL fixture proving it sees allocations from the real xmem provider. Please leave that cross-module ABI for the first such consumer. The outstanding noexcept allocation-failure review still applies.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073810486 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/327#issuecomment-7073810486). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:49:58Z. --- For this PR, keep the registry private to the module that owns it (option c) and preserve the four XMem exports. The direct-linked fixture can claim attach/lookup behavior within that module. A D3D12 client in another DLL needs a single shared registry and a two-DLL fixture proving it sees allocations from the real xmem provider. Please leave that cross-module ABI for the first such consumer. The outstanding noexcept allocation-failure review still applies.
thegl0w commented 2026-11-24 06:48:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thegl0w on 2026-11-22T04:41:59Z.


AI-generated: this comment was written by Claude (Claude Code), an AI assistant, and posted with the account owner's approval. The runs below were done on the account owner's PC.

Thanks, both points are addressed in 21a65e5 (docs in 348b785).

First-use initialization. The state is no longer created with a throwing new:

  • track and attach create it through a non-throwing step that publishes it with a compare-exchange. If the allocation fails, track returns false and attach returns E_OUTOFMEMORY. Nothing is registered, and a later call retries.
  • untrack, detach, translate, locate, shader_view and counts never create it. Without it they behave as for an empty registry.
  • Teardown: the state is still never destroyed. The pointer is a constant-initialized std::atomic<State*>, with a static_assert that it is trivially destructible, so loading and unloading the module run no code for it and release no D3D12 object.

Failure-path check, era_title_gpu_alloc (no GPU):

  • The program replaces the global operator new so that one chosen allocation fails, then fails every allocation of a first track (registry creation included) and of a later one, one at a time.
  • After each failure: track returned false; nothing is tracked, registered with era_query or translated; and the call is retried.
  • First track: 6 failure points. Later track: 2.
  • It also found a second instance of the same problem in my change: shader_view's empty result allocated under the debug STL inside a noexcept function. It now clears the caller's vectors.
  • An abort() is reported on stderr rather than through the debug CRT's dialog, and the test has a 30 s timeout.
  • Mutants: a throwing creation and the constructed empty view each end in abort() (exit 3). A counts that creates the registry, and a track that keeps the era_query registration after a failed insertion, each fail a check (exit 1).

Module boundary: I kept option (c). The registry stays private to the module that links it, xmem.dll keeps its four exports, and the header and docs now say so. The cross-module ABI and its two-DLL fixture are left for the first consumer.

Run at 21a65e5, Windows 11 build 26300, debug layer enabled:

  • the full suite, hardware included: 149/149 (3 capability skips);
  • gpu_alias_registry_hardware: 100 of 100 repeated runs on the RTX 3070;
  • gpu_alias_registry_warp: 50 of 50;
  • era_title_gpu_alloc: 50 of 50.

The PR description is updated to match.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7074325470 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/327#issuecomment-7074325470). Originally posted by [thegl0w](https://github.com/thegl0w) on 2026-11-22T04:41:59Z. --- > **AI-generated:** this comment was written by Claude (Claude Code), an AI assistant, and posted with the account owner's approval. The runs below were done on the account owner's PC. Thanks, both points are addressed in `21a65e5` (docs in `348b785`). **First-use initialization.** The state is no longer created with a throwing `new`: - `track` and `attach` create it through a non-throwing step that publishes it with a compare-exchange. If the allocation fails, `track` returns `false` and `attach` returns `E_OUTOFMEMORY`. Nothing is registered, and a later call retries. - `untrack`, `detach`, `translate`, `locate`, `shader_view` and `counts` never create it. Without it they behave as for an empty registry. - **Teardown:** the state is still never destroyed. The pointer is a constant-initialized `std::atomic<State*>`, with a `static_assert` that it is trivially destructible, so loading and unloading the module run no code for it and release no D3D12 object. **Failure-path check, `era_title_gpu_alloc`** (no GPU): - The program replaces the global `operator new` so that one chosen allocation fails, then fails every allocation of a first `track` (registry creation included) and of a later one, one at a time. - After each failure: `track` returned `false`; nothing is tracked, registered with `era_query` or translated; and the call is retried. - First `track`: 6 failure points. Later `track`: 2. - It also found a second instance of the same problem in my change: `shader_view`'s empty result allocated under the debug STL inside a `noexcept` function. It now clears the caller's vectors. - An `abort()` is reported on stderr rather than through the debug CRT's dialog, and the test has a 30 s timeout. - **Mutants:** a throwing creation and the constructed empty view each end in `abort()` (exit 3). A `counts` that creates the registry, and a `track` that keeps the `era_query` registration after a failed insertion, each fail a check (exit 1). **Module boundary:** I kept option (c). The registry stays private to the module that links it, `xmem.dll` keeps its four exports, and the header and docs now say so. The cross-module ABI and its two-DLL fixture are left for the first consumer. **Run at `21a65e5`,** Windows 11 build 26300, debug layer enabled: - the full suite, hardware included: 149/149 (3 capability skips); - `gpu_alias_registry_hardware`: 100 of 100 repeated runs on the RTX 3070; - `gpu_alias_registry_warp`: 50 of 50; - `era_title_gpu_alloc`: 50 of 50. The PR description is updated to match.
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!322
No description provided.