Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive vkAllocateMemory VUID-VkMemoryAllocateInfo-allocationSize-01743 #8874

Open
bangnoise opened this issue Nov 18, 2024 · 7 comments
Labels
Bug Something isn't working

Comments

@bangnoise
Copy link

Environment:

  • OS: Windows 11 Pro 23H2
  • GPU and driver version: GeForce RTX 3070 / 560.94
  • SDK or header version if building from repo: 1.3.296.0
  • Options enabled (synchronization, best practices, etc.):

Describe the Issue

When VkImportMemoryWin32HandleInfoKHR.handle has a VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT from a second process which matches a previously created and closed handle from the validated process, the validation layer incorrectly reports a mismatch between VkMemoryAllocateInfo.allocationSize and the size when the payload was created.

Expected behavior

No validation error should be reported.

Valid Usage ID

Additional context

Process 1: allocates 3360 bytes, calls vkGetMemoryWin32HandleKHR() -> 0xdb4
Process 1: ...
Process 1: CloseHandle(0xdb4), vkFreeMemory()
Process 2: allocates 41760 bytes, calls vkGetMemoryWin32HandleKHR() -> 0x1698
Process 2: DuplicateHandle(0x1698) -> 0xdb4
Process 2: sends 0xdb4 to Process 1
Process 1: vkAllocateMemory() with VkImportMemoryWin32HandleInfoKHR.handle 0xdb4 triggers false positive 3360 != 41760 but 3360 is the allocation of a previously deleted resource in Process 1

ERROR : VALIDATION - Message Id Number: -1224652074 | Message Id Name: VUID-VkMemoryAllocateInfo-allocationSize-01743
	Validation Error: [ VUID-VkMemoryAllocateInfo-allocationSize-01743 ] | MessageID = 0xb7014ad6 | vkAllocateMemory(): pAllocateInfo->allocationSize allocationSize (125280) does not match pAllocateInfo->pNext<VkImportMemoryWin32HandleInfoKHR>.handle (0x15fc) of type VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT allocationSize (41760).
The Vulkan spec states: If the parameters define an import operation, the external handle was created by the Vulkan API, and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT or VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, then the values of allocationSize and memoryTypeIndex must match those specified when the payload being imported was created (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkMemoryAllocateInfo-allocationSize-01743)
@spencer-lunarg
Copy link
Contributor

to be clear, when you say 2 processes here, are these the same VkInstance and VkDevice?

Or are you loading process one (which loads the validation layers) and process two is a whole new VkInstance?

@spencer-lunarg spencer-lunarg added the Bug Something isn't working label Nov 18, 2024
@bangnoise
Copy link
Author

The second process is a new VkInstance

@spencer-lunarg
Copy link
Contributor

@charles-lunarg / @artem-lunarg do you know if on Windows, if you create 2 VkInstance on 2 different processes, would the loader DLL be loaded once or twice?

If it is loaded only once, I assume the issue is the state tracking is somehow not mapping the value correctly to the dispatch handle?

@charles-lunarg
Copy link
Contributor

charles-lunarg commented Nov 18, 2024

@charles-lunarg / @artem-lunarg do you know if on Windows, if you create 2 VkInstance on 2 different processes, would the loader DLL be loaded once or twice?

Twice, the VkInstance and all DLL's are per-process.

@artem-lunarg
Copy link
Contributor

artem-lunarg commented Nov 18, 2024

@bangnoise Could you confirm that the application uses two different windows processes as opposed to two threads inside a single process?

@bangnoise
Copy link
Author

@artem-lunarg correct, these are two different Windows processes

@bangnoise
Copy link
Author

bangnoise commented Nov 21, 2024

We're getting false positives for VUID-VkMemoryDedicatedAllocateInfo-image-01876 too, and the underlying cause appears to be the same - erroneous entries in ValidationStateTracker::win32_handle_map_ from previously destroyed resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants