runtime/test: only release output pointer when SUCCEEDED(hr) in pipeline library host test (TEST-PIPELINE-LIBRARY-HOST-RELEASE) #1757

Open
github-bot wants to merge 2 commits from github-bot/gh-1757 into main AGit
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 11:20 UTC · original
abnalstlll-byte:feat/test-pipeline-library-host-release → main · +40 −7 · 3 files · 2 commits · open

Claimed in Issue #1608: claiming: TEST-PIPELINE-LIBRARY-HOST-RELEASE (#1608).

Summary

Resolves the finding by @⁠whoalin1 regarding d3d12_pipeline_library_host crashing with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN / fail-fast) on RTX 4070 SUPER and AMD gfx1036 (comment 7156997734).

In runtime/test/d3d12_pipeline_library_host_test.cpp:243:
one_step previously executed:

if (written && c.out && hr != HRESULT(kFaulted)) static_cast<IUnknown*>(c.out)->Release();

Calling Release() on an output pointer when FAILED(hr) (e.g. E_NOINTERFACE in step 13 "create: as ID3D12Fence" or E_INVALIDARG) violates COM interface conventions. When a driver or host runtime writes an invalid sentinel or uninitialized pointer on failure, invoking Release() triggers an immediate fail-fast exception (0xc0000409) or access violation that SEH __except (EXCEPTION_EXECUTE_HANDLER) cannot survive.

  • Guard the COM Release() call with SUCCEEDED(hr):
if (SUCCEEDED(hr) && written && c.out) static_cast<IUnknown*>(c.out)->Release();
  • Adds synthetic regression unit test tests/test_d3d12_pipeline_library_host_release.py.

Verification

  • python -I tests/test_d3d12_pipeline_library_host_release.py -> 1/1 PASS in 0.000s.
  • python -I scripts/check_no_game_data.py runtime/test/d3d12_pipeline_library_host_test.cpp tests/test_d3d12_pipeline_library_host_release.py -> Clean (0 violations).
  • 100% clean merge against upstream HEAD bcaa13dad.

AI-assisted (Claude Code).

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 11:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1757) `abnalstlll-byte:feat/test-pipeline-library-host-release` → `main` · +40 −7 · 3 files · 2 commits · open Claimed in Issue #1608: `claiming: TEST-PIPELINE-LIBRARY-HOST-RELEASE` (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). ### Summary Resolves the finding by @⁠whoalin1 regarding `d3d12_pipeline_library_host` crashing with `0xc0000409` (STATUS_STACK_BUFFER_OVERRUN / fail-fast) on RTX 4070 SUPER and AMD gfx1036 (comment 7156997734). In `runtime/test/d3d12_pipeline_library_host_test.cpp:243`: `one_step` previously executed: ```cpp if (written && c.out && hr != HRESULT(kFaulted)) static_cast<IUnknown*>(c.out)->Release(); ``` Calling `Release()` on an output pointer when `FAILED(hr)` (e.g. `E_NOINTERFACE` in step 13 "create: as ID3D12Fence" or `E_INVALIDARG`) violates COM interface conventions. When a driver or host runtime writes an invalid sentinel or uninitialized pointer on failure, invoking `Release()` triggers an immediate fail-fast exception (`0xc0000409`) or access violation that SEH `__except (EXCEPTION_EXECUTE_HANDLER)` cannot survive. - Guard the COM `Release()` call with `SUCCEEDED(hr)`: ```cpp if (SUCCEEDED(hr) && written && c.out) static_cast<IUnknown*>(c.out)->Release(); ``` - Adds synthetic regression unit test `tests/test_d3d12_pipeline_library_host_release.py`. ### Verification - `python -I tests/test_d3d12_pipeline_library_host_release.py` -> 1/1 PASS in 0.000s. - `python -I scripts/check_no_game_data.py runtime/test/d3d12_pipeline_library_host_test.cpp tests/test_d3d12_pipeline_library_host_release.py` -> Clean (0 violations). - 100% clean merge against upstream HEAD `bcaa13dad`. AI-assisted (Claude Code).
In d3d12_pipeline_library_host_test.cpp:one_step, calling Release() whenever
written && c.out && hr != kFaulted violates COM rules when calls return an error
HRESULT (such as E_NOINTERFACE or E_INVALIDARG on unsupported interfaces/blobs).
Certain drivers write invalid sentinels or partial pointers on failure, which causes
unhandled access violations or fast-fail (0xc0000409) that SEH cannot catch.

Only release c.out when SUCCEEDED(hr) && written && c.out. Resolves whoalin1 finding.
Adds regression unit test 	ests/test_d3d12_pipeline_library_host_release.py.
Address review feedback from @PierreEbele:
1. In runtime/test/d3d12_pipeline_library_host_test.cpp:one_step, preserve hr != HRESULT(kFaulted)
   alongside SUCCEEDED(hr). Because kFaulted (0xFA017ED) has a positive sign bit, SUCCEEDED() alone
   would evaluate to true on faulted steps, triggering an unhandled 0xc0000409 crash on release.
2. Guard d3d12_pipeline_library_host_test in runtime/CMakeLists.txt with if(MSVC) to explicitly
   require MSVC SEH support.
3. Update tests/test_d3d12_pipeline_library_host_release.py regression test.

AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:50 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 18:24 UTC · original

Reviewed 22c7a93: ran the new regression test (passes on the PR, fails when copied onto main, so it does pin the change) plus test_ci_registration and check_no_game_data, both clean; the C++ test itself needs Windows/MSVC (SEH), so I could not run it here. The SUCCEEDED(hr) guard does fix the reported E_NOINTERFACE-style release of garbage out-pointers, but it also drops the old hr != HRESULT(kFaulted) exclusion, and kFaulted (0xFA017ED) is a positive HRESULT, so SUCCEEDED(kFaulted) is true: a step whose call raised an exception after writing its out pointer - the partially initialized driver object case the message describes - is released again, outside the SEH guard, i.e. the uncatchable fail-fast class. Probe decision table (guard arithmetic from the source): kFaulted + written + c.out -> main skips Release, PR calls it; E_NOINTERFACE + written -> main called it, PR skips it (the intended fix). The residency test already uses hr != kFaulted && SUCCEEDED(...); suggest if (hr != HRESULT(kFaulted) && SUCCEEDED(hr) && written && c.out) and pinning both terms in the test. Whether any current host step faults after writing its output needs a Windows run. Could not check the coordination-issue claim (no GitHub access).

AI-assisted review.

Recommendation: Fix first

**@⁠PierreEbele** on GitHub · 2026-11-25 18:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1757#issuecomment-7170865718) Reviewed 22c7a93: ran the new regression test (passes on the PR, fails when copied onto main, so it does pin the change) plus test_ci_registration and check_no_game_data, both clean; the C++ test itself needs Windows/MSVC (SEH), so I could not run it here. The SUCCEEDED(hr) guard does fix the reported E_NOINTERFACE-style release of garbage out-pointers, but it also drops the old `hr != HRESULT(kFaulted)` exclusion, and kFaulted (0xFA017ED) is a positive HRESULT, so SUCCEEDED(kFaulted) is true: a step whose call raised an exception after writing its out pointer - the partially initialized driver object case the message describes - is released again, outside the SEH guard, i.e. the uncatchable fail-fast class. Probe decision table (guard arithmetic from the source): kFaulted + written + c.out -> main skips Release, PR calls it; E_NOINTERFACE + written -> main called it, PR skips it (the intended fix). The residency test already uses `hr != kFaulted && SUCCEEDED(...)`; suggest `if (hr != HRESULT(kFaulted) && SUCCEEDED(hr) && written && c.out)` and pinning both terms in the test. Whether any current host step faults after writing its output needs a Windows run. Could not check the coordination-issue claim (no GitHub access). AI-assisted review. **Recommendation:** Fix first
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 21:37 UTC · original

Thanks @⁠PierreEbele! Updated in 5e4ae90a7:

  • Preserved \hr != HRESULT(kFaulted)\ alongside \SUCCEEDED(hr)\ in \one_step\ (matching \d3d12_residency_test.cpp:393) so positive-sign \kFaulted\ (0xFA017ED) steps never attempt an unhandled Release outside SEH.
  • Guarded \d3d12_pipeline_library_host_test\ in
    untime/CMakeLists.txt\ with \if(MSVC)\ to explicitly enforce the MSVC SEH compiler requirement.
  • Rebased cleanly onto latest \main\ (\e34ff17e9).

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 21:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1757#issuecomment-7175320394) Thanks @⁠PierreEbele! Updated in 5e4ae90a7: - Preserved \hr != HRESULT(kFaulted)\ alongside \SUCCEEDED(hr)\ in \one_step\ (matching \d3d12_residency_test.cpp:393\) so positive-sign \kFaulted\ (0xFA017ED) steps never attempt an unhandled Release outside SEH. - Guarded \d3d12_pipeline_library_host_test\ in \ untime/CMakeLists.txt\ with \if(MSVC)\ to explicitly enforce the MSVC SEH compiler requirement. - Rebased cleanly onto latest \main\ (\e34ff17e9\). AI-assisted (Claude Code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1757/head:github-bot/gh-1757'
git switch 'github-bot/gh-1757'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1757'
git switch 'github-bot/gh-1757'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1757'
git switch 'github-bot/gh-1757'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1757'
git switch 'main'
git merge --squash 'github-bot/gh-1757'
git switch 'main'
git merge --ff-only 'github-bot/gh-1757'
git switch 'main'
git merge 'github-bot/gh-1757'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.