Skip to content

D3D12-GPU-SHOWN-SAVER-EVENT-DROP: close shown saver event handle on drop - #3003

Open
bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:fix/d3d12-gpu-shown-saver-event-drop
Open

bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:fix/d3d12-gpu-shown-saver-event-drop

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

Addresses claim in #2570 (comment).

Cause

shown::saver (d3d12/crates/leonida-gpu/src/shown.rs) creates an unnamed auto-reset event via CreateEventW(None, false, false, None) and returns on channel close or HOOK.get() None without closing the HANDLE.

Fix

  • Wrap the event HANDLE in EventHandle, closing it via CloseHandle and clearing self.0 on Drop.
  • Add shown::tests::event_handle_drop_closes_event_handle verifying in an isolated --exact subprocess (GetHandleInformation) that dropping EventHandle closes the OS handle.

Verification

  • Red -> Green: With CloseHandle stubbed in EventHandle::drop, shown::tests::event_handle_drop_closes_event_handle fails (RED_SHOWN_EXIT=101); with Drop active, shown::tests passes (1 passed, 0 failed).
  • Default feature build (cargo test --locked -p leonida-gpu --lib -- shown::tests) compiles cleanly.
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/shown.rs: exit 0.
  • Independent read-only code review: approved.

AI-assisted

@andrew-ai

Copy link
Copy Markdown

Verified both exits through saver() at 679938d on native Windows. A temporary crate test used a real D3D12 device, warmed each path once, then measured the process handle count with GetProcessHandleCount across 64 calls. The parent saver function and the PR saver ran in the same isolated test process.

Saver exit Parent handle delta PR handle delta
Queue closed without a job +64 0
One queued job, capture hook absent +64 0

This reproduces one leaked handle per invocation on the parent and verifies both cleanup paths on the PR. No frame capture or fence completion was exercised. Codex-assisted.

@merzleckeier

Copy link
Copy Markdown
Contributor

Both actual saver exits release the event under Wine, including with the replay handle fix applied.

I cross-built Win64 with --features diagnostics on 913b88b90. The control had #2994 alone. The candidate added 679938d2. The candidate shown.rs matches the isolated #3003 integration. I added the same test-only probe to observe the handle the real saver() creates. It confirms the handle is valid immediately after CreateEventW and queries that same handle right after saver() returns.

On both RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1), I ran eight calls per GPU per exit path. For a closed queue and for a queued synthetic job with the sender still open and HOOK absent, all 32 control calls left the event live. All 32 candidate calls returned ERROR_INVALID_HANDLE for the event after return. The stock shown EventHandle and #2994 replay Worker controls also both passed on each GPU. This checks saver teardown and the combination under Wine 11.22 / VKD3D-Proton 3.1.0. No swapchain capture or fence completion was exercised. AI-assisted with OpenAI Codex and independent raw-result verification.

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.

3 participants