wine icon indicating copy to clipboard operation
wine copied to clipboard

sharedgpures: fix dispatch_close decrementing ref_count for handles that never opened a resource

Open dollthing opened this issue 9 months ago • 0 comments

When a process opens the \Device\SharedGpuResource device but the subsequent IOCTL_SHARED_GPU_RESOURCE_OPEN fails (e.g. invalid KMT handle), FsContext is never updated from its default value of 0. dispatch_close unconditionally computes &resource_pool[FsContext] and decrements ref_count, which erroneously frees whatever resource happens to be at index 0.

This is particularly damaging when DXVK retries failed OPEN ioctls thousands of times via the D3DKMT DDI path (when NtGdiDdDDIQueryResourceInfo is stubbed), as each open/close cycle decrements resource_pool[0].ref_count.

Fix by initializing FsContext to (UINT_PTR)-1 as a sentinel in dispatch_create, and skipping cleanup in dispatch_close when the sentinel is still set.


This is one of two PRs needed to make Wine/Proton & Spout2PW work with VNyan under Linux. The other PR is #312.

dollthing avatar Feb 20 '26 07:02 dollthing