KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
761 stars 403 forks source link

pNext's pointer could be invalid if the struct is released in application layer. #920

Closed locke-lunarg closed 5 years ago

locke-lunarg commented 5 years ago

See the those links PR #912 & issue #905 & PR #918 . Those pNext's pointer could be invalid if the struct is released in application layer.

Now I copied the necessary data and avoided to use pNext. Do we need a better solution to deal with the issue? @mikes-lunarg @jzulauf-lunarg @mark-lunarg

issue #248 looks to relate to this issue,

mikes-lunarg commented 5 years ago

Yes I think so, otherwise this will keep happening. Creating a proper deep copy is the most straightforward way to do this, the layer chassis already does something similar with pNext chains containing handles that need to be unwrapped. The known vs unknown struct issue on #248 isn't really a problem for copies we keep for validation, since we wouldn't be looking at those fields anyway.

An alternate approach would be to null out pNext chains for copies and separately copy the relevant extension structs to store "on the side", similar to what you have been doing in the linked PRs. Upside would be fewer allocations/copies, downside would be more complexity in the validation code to track the extra data.