Skip to content

d3d12_existing_heap_test: a real event handle instead of 0x1234 (0xC0000008 under strict handle checks); the layer refuses a non-section handle as the host does - #7357

Open
tibzejoker wants to merge 1 commit into
ItsNotRexed:mainfrom
tibzejoker:existing-heap-test-handle

Conversation

@tibzejoker

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #7333 (comment) (from my finding in #7231).

What and why

d3d12_existing_heap_test (from #4538) passed the made-up handle (HANDLE)0x1234 to OpenExistingHeapFromFileMapping. With strict handle checking on (Application Verifier, a debugger, some security software), GetHandleInformation raises STATUS_INVALID_HANDLE on it instead of returning FALSE, so the test ended with 0xC0000008 before printing anything. @umnitus saw it on an RTX 3060 / NVIDIA 621.14 on main 8575d36e, with validation on and off.

  • Test: the refusal now uses an event, a real handle that isn't a section.
  • Layer: that showed a real difference. For an event handle, the host runtime answers E_INVALIDARG (RTX 4090 and WARP), while the Vulkan layer answered E_NOTIMPL, because it only checked that the handle was valid. OpenExistingHeapFromFileMapping now also checks that the handle names a section object, from NtQueryObject's type name, with nothing mapped. If NtQueryObject isn't available, the handle counts as a section, which keeps the old behaviour.

Tested

RTX 4090, driver 617.42, Windows 11 26200, MSVC 2022 RelWithDebInfo, LEONIDA_VK_VALIDATION=1: d3d12_existing_heap_test passes on the Vulkan device, the RTX 4090 host device and WARP, with no validation errors. Before the layer change, the new assertion failed on the Vulkan device only (0x80004001 vs the host's 0x80070057).

Not reproduced here: the 0xC0000008 itself, since this machine doesn't have strict handle checking. The fix removes the bogus handle that causes it. Synthetic only, no game data.

AI-assisted: yes (Claude Code).

🤖 Generated with Claude Code

…layer refuses a non-section handle as the host does

The test passed the made-up handle (HANDLE)0x1234 to OpenExistingHeapFromFileMapping. Under strict
handle checking (Application Verifier, a debugger, some security software) GetHandleInformation raises
STATUS_INVALID_HANDLE on it, so the test ended with 0xC0000008 before printing anything (an RTX 3060
setup, on main and on ItsNotRexed#7218). It now uses an event, a real handle that is not a section.

That exposed a difference: the host runtime answers E_INVALIDARG for an event handle on the RTX 4090 and
WARP, and the Vulkan layer answered E_NOTIMPL, because it only checked that the handle was valid. It now
also checks that the handle names a section object (NtQueryObject's type name; nothing is mapped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: test builds and passes cleanly. Validating real event handle usage (CreateEventW) avoids STATUS_INVALID_HANDLE (

@dadsmallbuk1

Copy link
Copy Markdown

Tested f5de0db on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), native MSVC 2022 RelWithDebInfo: pass.

  • ctest -R d3d12_existing_heap: 1/1 pass. The event handle is refused with E_INVALIDARG, as on the host.
  • Code read: the shim's new is_section_handle only queries the handle's type name with NtQueryObject (nothing is mapped), and treats an unavailable query as a section, which keeps the old behaviour. The test now uses a real event handle instead of 0x1234, so strict handle checking no longer turns the check into 0xC0000008. I didn't run it under Application Verifier.

AI-assisted (Claude Code).

@illusionart453-max

Copy link
Copy Markdown

Independent native Windows/MSVC 19.44, RTX 5060 driver 32.0.16.1088: #7357 diff applied cleanly to main 8575d36 (review checkout already has the unrelated #7125 test correction). Rebuilt d3d12_existing_heap_test, RelWithDebInfo, and ran it: exit 0. Existing-heap and lifetime-tracker refusals match on Vulkan, native RTX 5060 and WARP. Strict handle checking and validation layer unavailable here, so original STATUS_INVALID_HANDLE was not reproduced. Build emitted pre-existing vulkan_present.h:669 C4189 and TEMP MSB8029. Synthetic handles only, no game files. AI-assisted (Codex).

@umnitus

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Retested on the Windows / RTX 3060 12 GB setup that previously reproduced 0xC0000008 in #7218. At f5de0db, the unmodified d3d12_existing_heap CTest passed with NVIDIA 621.14, clang-cl/xwin SDK 10.0.26100 and Khronos validation 1.4.363. Native NVIDIA D3D12 and WARP refusal checks also passed. AI-assisted testing.

@MeNoSkills

MeNoSkills commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested f5de0db on Windows 10 22H2 (19045), MSVC 2022, Vulkan SDK 1.4.363: pass for the change.

  • ctest -R d3d12_existing_heap: Passed on NVIDIA GeForce RTX 4070 Ti and on AMD Radeon Graphics (gfx1036 iGPU, driver 24.30.18), selected with LEONIDA_VK_DEVICE.
  • I could not reproduce the original 0xC0000008 here (no Application Verifier or strict handle checking), so this shows the test passes with the event handle, not that the exception is gone.
  • ctest -R d3d12_vulkan_device fails on both GPUs, identically on main e0816d6, so it is not caused by this PR: NVIDIA line 6564: tiles == 1 (the CreateReservedResource2 / GetResourceTiling check); AMD line 5533: argument_mismatches <= 0 (invalid arguments format 67 RT: ours 0x00000000, host 0x80070057).

(My first version of this comment blamed allocation-info size lines; those are only printed, not the failing assertions. Corrected.)

AI-assisted (Claude Code).

@svds12343

Copy link
Copy Markdown

Independent controlled strict-handle check of f5de0db: PASS, with the original 0xC0000008 reproduced as a negative control.

Claim: #7333 (comment)
Environment: native Windows 11 Pro N build 26200, MSVC 19.44.35230 / Windows SDK 10.0.26100, RelWithDebInfo, RTX 3070 / NVIDIA 610.88, Vulkan SDK and Khronos validation 1.4.363.0. Synthetic handles only; no game files.

Test source Child handle policy Vulkan validation off Vulkan validation on
Unchanged PR test Default Pass Pass
Unchanged PR test Strict, both flags read back as 1 Pass Pass
Parent's original bogus-handle test Default Pass Pass
Parent's original bogus-handle test Strict, both flags read back as 1 0xC0000008 0xC0000008

All six successful runs completed the Vulkan, native NVIDIA D3D12 and WARP refusal checks. The validation-on PR runs printed (validation on) and exited 0 with no validation diagnostics. The two expected crashes happened before the test's success lines were flushed, consistent with the original empty-output symptom.

Method: a separate launcher uses CreateProcessW with STARTUPINFOEXW, PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY and PROCESS_CREATION_MITIGATION_POLICY_STRICT_HANDLE_CHECKS_ALWAYS_ON. It creates the child suspended, queries GetProcessMitigationPolicy(child, ProcessStrictHandleCheckPolicy), requires RaiseExceptionOnInvalidHandleReference=1 and HandleExceptionsPermanentlyEnabled=1, then resumes and records the child exit code. This changes the child process policy only; no registry, system-wide mitigation or Application Verifier configuration was changed. The policy is documented by Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute

The PR's test and runtime source were unchanged. For the negative control I compiled HEAD^:runtime/test/d3d12_existing_heap_test.cpp as a second local target linked to the SAME PR library. This isolates replacement of the bogus handle; it is not a claim that the entire parent revision was built. Local CMake additions only register that extra target. I did not repeat the author's separate E_NOTIMPL-before/E_INVALIDARG-after runtime comparison.

Build: cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo; cmake --build runtime/build --target d3d12_existing_heap_test strict_original_heap_test -j 6. The existing vulkan_present.h:669 C4189 warning appears twice. Fresh head/coordination recheck completed; merge-tree with main 86d1c86 is clean. Tests were of the exact PR head, not that speculative merge.

AI-assisted (Codex). This fills the controlled strict-policy reproduction gap in the earlier reviews; no replacement implementation PR.

@nullmarsh

Copy link
Copy Markdown

Tested f5de0dbf natively on Windows 11 26200, MSVC 14.44, RX 9060 XT (AMD 26.11.2): pass. d3d12_existing_heap prints existing-heap and lifetime-tracker refusals match the host runtime for the Vulkan layer, host AMD Radeon RX 9060 XT and host WARP, so the non-section-handle refusal matches the AMD driver's native D3D12 too. Not run under strict handle checking.

AI-assisted (Claude Code), no game files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants