The five indirect tests fault at process exit: static pipeline states are destroyed during teardown #2564

Closed
opened 2026-11-25 21:26:54 +00:00 by thepatrickworld · 3 comments
thepatrickworld commented 2026-11-25 21:26:54 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-25T21:26:54Z.


The five indirect tests fault at process exit: static pipeline states are destroyed during teardown

startup_indirect_translated_indexed_hardware, …_upload_hardware, …_rect_hardware, …_alias_hardware and startup_indirect_rectlist_hardware exit with 0xc0000409 on an AMD adapter (RX 9070 XT, driver 32.0.32029.2010, Windows 11 25H2 26200.9974). No check inside them reports a failure; the process dies at exit, after the last readback returns.

The dump. LocalDumps at DumpType=2, read with cdb. Eight frames of twenty-five, ExceptionCode c0000409:

amdxc64          (faulting instruction at 0x42022a19)
D3D12Core!CPipelineState::FinalRelease+0x4d
D3D12Core!CLayeredObject<CPipelineState>::Release+0x9
d3d12_xs!Microsoft::WRL::ComPtr<ID3D12PipelineState>::InternalRelease+0x43
d3d12_xs!`anonymous namespace'::IndexedValidationPipeline::~IndexedValidationPipeline+0x1b
d3d12_xs!``anonymous namespace'::indexed_validation_pipeline'::`2'::`dynamic atexit destructor for 'validation''
d3d12_xs!__crt_seh_guarded_call<...>::operator()
d3d12_xs!_execute_onexit_table+0x34

The symbol names amdxc64 resolves to (GetSettingsBlobsAll, is_destroyed, …) are nearest-symbol artefacts of a module shipped without public symbols, so ignore them. The offset is what matters: 0x42022a19 minus image base 0x3ea30000 is 0x35f2a19, the same offset as the ten Application-log entries that pointed at this DLL in the first place.

0xc0000409 with subcode 7 is FAST_FAIL_FATAL_APP_EXIT — the code the CRT itself uses for abort()/terminate. It says the process was killed on purpose, not that memory was corrupted. A CPipelineState::FinalRelease issued from a dynamic atexit destructor reaches the UMD during DLL detach, and the UMD calls __fastfail(7).

Two sites own pipeline states in function-local statics:

  • src/startup_stubs/d3d12_draw.inl:1604 — static IndexedValidationPipeline validation, holding device, root signature and PSO. Captures the first device for the life of the shim (guard at l. 1637); there has never been a per-device cache here.
  • src/startup_stubs/rect_indirect_args.h:153 — static RectIndirectArguments converter, whose entries_ hold one PSO per device.

(A third static, d3d12_xs_device.cpp:4103, holds ComPtr<ID3D12Resource> pages on the cross-adapter placed-buffer path — same shape, different object, not exercised by these five.)

The experiment. Rows are command lines, one run each; the third column removes the destructor of that row's own site (heap-allocate, never delete), nothing else:

command stock that row's own site changed
startup_indirect_draw_indexed hardware translated-indexed 0xc0000409 0
startup_indirect_draw_indexed hardware rect (= startup_indirect_rectlist_hardware) 0xc0000409 0
control: hardware translated-indexed with only the rect site changed 0xc0000409 0xc0000409

Each site is responsible for its own path, and the control shows the change is not a blanket effect. The three other variants were not instrumented one by one; they are the same family and share the d3d12_draw.inl site.

WARP is clean because amdxc64 is never loaded there, not because the release path becomes harmless.

Direction. Not just relocating a destructor: indexed_validation_pipeline is a process-wide singleton that keeps whichever device came first, so a per-device cache is a design change, not a lifetime fix. I can prepare a branch that way if it suits you.

Reproduced on main at b976e8bc. Machine: RX 9070 XT (1002:7550), driver 32.0.32029.2010.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6614087456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2572). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T21:26:54Z. --- ## The five indirect tests fault at process exit: static pipeline states are destroyed during teardown `startup_indirect_translated_indexed_hardware`, `…_upload_hardware`, `…_rect_hardware`, `…_alias_hardware` and `startup_indirect_rectlist_hardware` exit with `0xc0000409` on an AMD adapter (RX 9070 XT, driver `32.0.32029.2010`, Windows 11 25H2 26200.9974). No check inside them reports a failure; the process dies at exit, after the last readback returns. **The dump.** `LocalDumps` at `DumpType=2`, read with `cdb`. Eight frames of twenty-five, `ExceptionCode c0000409`: ``` amdxc64 (faulting instruction at 0x42022a19) D3D12Core!CPipelineState::FinalRelease+0x4d D3D12Core!CLayeredObject<CPipelineState>::Release+0x9 d3d12_xs!Microsoft::WRL::ComPtr<ID3D12PipelineState>::InternalRelease+0x43 d3d12_xs!`anonymous namespace'::IndexedValidationPipeline::~IndexedValidationPipeline+0x1b d3d12_xs!``anonymous namespace'::indexed_validation_pipeline'::`2'::`dynamic atexit destructor for 'validation'' d3d12_xs!__crt_seh_guarded_call<...>::operator() d3d12_xs!_execute_onexit_table+0x34 ``` The symbol names `amdxc64` resolves to (`GetSettingsBlobsAll`, `is_destroyed`, …) are nearest-symbol artefacts of a module shipped without public symbols, so ignore them. The offset is what matters: `0x42022a19` minus image base `0x3ea30000` is `0x35f2a19`, the same offset as the ten Application-log entries that pointed at this DLL in the first place. `0xc0000409` with subcode `7` is `FAST_FAIL_FATAL_APP_EXIT` — the code the CRT itself uses for `abort()`/`terminate`. It says the process was killed on purpose, not that memory was corrupted. A `CPipelineState::FinalRelease` issued from a **dynamic atexit destructor** reaches the UMD during DLL detach, and the UMD calls `__fastfail(7)`. **Two sites own pipeline states in function-local statics:** - `src/startup_stubs/d3d12_draw.inl:1604` — `static IndexedValidationPipeline validation`, holding device, root signature and PSO. Captures the first device for the life of the shim (guard at l. 1637); there has never been a per-device cache here. - `src/startup_stubs/rect_indirect_args.h:153` — `static RectIndirectArguments converter`, whose `entries_` hold one PSO per device. (A third static, `d3d12_xs_device.cpp:4103`, holds `ComPtr<ID3D12Resource>` pages on the cross-adapter placed-buffer path — same shape, different object, not exercised by these five.) **The experiment.** Rows are command lines, one run each; the third column removes the destructor of *that row's own* site (heap-allocate, never delete), nothing else: | command | stock | that row's own site changed | |---|---|---| | `startup_indirect_draw_indexed hardware translated-indexed` | `0xc0000409` | **`0`** | | `startup_indirect_draw_indexed hardware rect` (= `startup_indirect_rectlist_hardware`) | `0xc0000409` | **`0`** | | control: `hardware translated-indexed` with only the rect site changed | `0xc0000409` | `0xc0000409` | Each site is responsible for its own path, and the control shows the change is not a blanket effect. The three other variants were not instrumented one by one; they are the same family and share the `d3d12_draw.inl` site. WARP is clean because `amdxc64` is never loaded there, not because the release path becomes harmless. **Direction.** Not just relocating a destructor: `indexed_validation_pipeline` is a process-wide singleton that keeps whichever device came first, so a per-device cache is a design change, not a lifetime fix. I can prepare a branch that way if it suits you. Reproduced on `main` at `b976e8bc`. Machine: RX 9070 XT (`1002:7550`), driver `32.0.32029.2010`. _AI-assisted._
R0Y00 commented 2026-11-25 22:02:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:36:38Z.


Please take the teardown fix for the two caches you isolated. Keep the current device-keying behavior in this first patch and make the lifetime boundary explicit. We need both normal process exit and explicit unload; the latter must still release the owned objects. #2470’s compute cache has a separate process-termination fix and can serve as a reference for the distinction. Windows DLL detach guidance

Please rerun all five startup_indirect_*_hardware cases listed here on the RX 9070 XT at one exact revision. Record the last successful readback and the child exit status separately, plus the adapter, driver and debug-layer state. Keep the per-site controls: leaving either original destructor active should still reproduce its own failure. Please use a source-built load/use/unload check to show normal cleanup remains intact. Logs and dumps stay local.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175306442 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2572#issuecomment-7175306442). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T21:36:38Z. --- Please take the teardown fix for the two caches you isolated. Keep the current device-keying behavior in this first patch and make the lifetime boundary explicit. We need both normal process exit and explicit unload; the latter must still release the owned objects. #2470’s compute cache has a separate process-termination fix and can serve as a reference for the distinction. [Windows DLL detach guidance](https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain) Please rerun all five `startup_indirect_*_hardware` cases listed here on the RX 9070 XT at one exact revision. Record the last successful readback and the child exit status separately, plus the adapter, driver and debug-layer state. Keep the per-site controls: leaving either original destructor active should still reproduce its own failure. Please use a source-built load/use/unload check to show normal cleanup remains intact. Logs and dumps stay local.
thepatrickworld commented 2026-11-25 23:02:05 +00:00 (Migrated from github.com)
Author
Contributor

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


Taken, as #2590 (fb5f5e62, branch panam/2572-teardown, cut from main at 8f045aee). Device keying is unchanged; the lifetime boundary is written down in src/startup_stubs/d3d12_teardown.h.

How the two detaches are told apart. DllMain in src/d3d12_xs_shim.cpp sets a flag when reason == DLL_PROCESS_DETACH && lpReserved, and on MSVC the user entry runs before this module's atexit table, so both destructors read it. On the terminating path they Detach(); on FreeLibrary (lpReserved == nullptr) they release, so an unload still gives the objects back.

The five runs at one revision — fb5f5e62, tree clean. The child exit status is the executable's own, run directly with the arguments its add_test line passes, not the code ctest reports:

run (arguments after hardware) last readback before exit child status
translated-indexed a guest root call without a desktop root retains native compute arguments: 4/8 non-clear pixels, argument guards intact 0
translated-indexed-upload readable CPU memory without recording ownership refused: 0/8 non-clear pixels, argument guards intact 0
translated-indexed-rect refuse an unmatched rectangle corner: 0/8 non-clear pixels, argument guards intact 0
translated-indexed-alias R32 with base 3 and both inputs on one GPU-aliased page: 4/8 non-clear pixels, argument guards intact 0
rect concurrent two rectangles: 8/8 non-clear pixels, argument guards intact 0

All five read 0xC0000409 before this change, after passing every check.

Environment: Windows 11 25H2 26200.9974, MSVC 19.44.35230, AMD Radeon RX 9070 XT (1002:7550, PCI\VEN_1002&DEV_7550&SUBSYS_E4891DA2), driver 32.0.32029.2010. Debug layer: unavailable, d3d12SDKLayers.dll is absent from System32 (d3d12core.dll 10.0.26100.9818), so no validation layer was active in any of these runs.

Per-site controls. Each is the same tree with one destructor removed, back to the original teardown, rebuilt and run the same way; child status again, no ctest in the way:

build the four translated-indexed* rect
both destructors (this patch) 0 0
validation-pipeline destructor removed -1073740791 0
converter destructor removed 0 -1073740791

-1073740791 is 0xC0000409. Each site brings back its own failure and only its own.

Load / use / unload, source-built. tests/startup_teardown_unload.cpp loads the built d3d12_xs.dll by path, warms both caches through a probe (x2w_d3d12_cached_objects_probe), calls FreeLibrary, and requires the device's reference count to come back and the module to be gone; a second load is warmed and left loaded so process termination exercises the other path. It passes on WARP and on the card. No title is involved.

Not covered here: the third static the issue names, the ComPtr<ID3D12Resource> pages in src/startup_stubs/d3d12_xs_device.cpp:4103, which is on the cross-adapter placed-buffer path and is untouched by this patch; and an explicit unload while a title still holds the device.

Logs and dumps stayed local.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176251689 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2572#issuecomment-7176251689). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T22:21:01Z. --- Taken, as #2590 (`fb5f5e62`, branch `panam/2572-teardown`, cut from `main` at `8f045aee`). Device keying is unchanged; the lifetime boundary is written down in `src/startup_stubs/d3d12_teardown.h`. **How the two detaches are told apart.** `DllMain` in `src/d3d12_xs_shim.cpp` sets a flag when `reason == DLL_PROCESS_DETACH && lpReserved`, and on MSVC the user entry runs before this module's `atexit` table, so both destructors read it. On the terminating path they `Detach()`; on `FreeLibrary` (`lpReserved == nullptr`) they release, so an unload still gives the objects back. **The five runs at one revision** — `fb5f5e62`, tree clean. The child exit status is the executable's own, run directly with the arguments its `add_test` line passes, not the code `ctest` reports: | run (arguments after `hardware`) | last readback before exit | child status | |---|---|---| | `translated-indexed` | `a guest root call without a desktop root retains native compute arguments: 4/8 non-clear pixels, argument guards intact` | `0` | | `translated-indexed-upload` | `readable CPU memory without recording ownership refused: 0/8 non-clear pixels, argument guards intact` | `0` | | `translated-indexed-rect` | `refuse an unmatched rectangle corner: 0/8 non-clear pixels, argument guards intact` | `0` | | `translated-indexed-alias` | `R32 with base 3 and both inputs on one GPU-aliased page: 4/8 non-clear pixels, argument guards intact` | `0` | | `rect` | `concurrent two rectangles: 8/8 non-clear pixels, argument guards intact` | `0` | All five read `0xC0000409` before this change, after passing every check. Environment: Windows 11 25H2 `26200.9974`, MSVC `19.44.35230`, AMD Radeon RX 9070 XT (`1002:7550`, `PCI\VEN_1002&DEV_7550&SUBSYS_E4891DA2`), driver `32.0.32029.2010`. Debug layer: unavailable, `d3d12SDKLayers.dll` is absent from `System32` (`d3d12core.dll` `10.0.26100.9818`), so no validation layer was active in any of these runs. **Per-site controls.** Each is the same tree with one destructor removed, back to the original teardown, rebuilt and run the same way; child status again, no `ctest` in the way: | build | the four `translated-indexed*` | `rect` | |---|---|---| | both destructors (this patch) | `0` | `0` | | validation-pipeline destructor removed | `-1073740791` | `0` | | converter destructor removed | `0` | `-1073740791` | `-1073740791` is `0xC0000409`. Each site brings back its own failure and only its own. **Load / use / unload, source-built.** `tests/startup_teardown_unload.cpp` loads the built `d3d12_xs.dll` by path, warms both caches through a probe (`x2w_d3d12_cached_objects_probe`), calls `FreeLibrary`, and requires the device's reference count to come back and the module to be gone; a second load is warmed and left loaded so process termination exercises the other path. It passes on WARP and on the card. No title is involved. Not covered here: the third static the issue names, the `ComPtr<ID3D12Resource>` pages in `src/startup_stubs/d3d12_xs_device.cpp:4103`, which is on the cross-adapter placed-buffer path and is untouched by this patch; and an explicit unload while a title still holds the device. Logs and dumps stayed local. _AI-assisted._
R0Y00 commented 2026-11-25 23:02:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:25:46Z.


Fixed by #2590, now on main at 157a477f. The report above confirms all five originally affected RX 9070 XT cases exited 0 after their readbacks on fb5f5e62, and the two per-cache controls restored only their respective failures. I independently rebuilt the merged PR head 1e903e8c and ran ctest --preset release --no-tests=error -R '^startup_teardown_unload_' -V: WARP and RTX 4060 Laptop both passed, with zero skips. Explicit DLL unload returned the device to its pre-warm reference count for each cache, and the process-exit case completed. Closing the five-test teardown regression on that evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176350483 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2572#issuecomment-7176350483). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T22:25:46Z. --- Fixed by #2590, now on `main` at `157a477f`. The report above confirms all five originally affected RX 9070 XT cases exited 0 after their readbacks on `fb5f5e62`, and the two per-cache controls restored only their respective failures. I independently rebuilt the merged PR head `1e903e8c` and ran `ctest --preset release --no-tests=error -R '^startup_teardown_unload_' -V`: WARP and RTX 4060 Laptop both passed, with zero skips. Explicit DLL unload returned the device to its pre-warm reference count for each cache, and the process-exit case completed. Closing the five-test teardown regression on that evidence.
Sign in to join this conversation.
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#2564
No description provided.