KhronosGroup / Vulkan-ValidationLayers

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

layers: Avoid using references to out-of-scope strings #8160

Closed kocdemir closed 2 weeks ago

kocdemir commented 2 weeks ago

Fixes possible crashes when using message filters and other string lists.

ci-tester-lunarg commented 2 weeks ago

Author kocdemir not on autobuild list. Waiting for curator authorization before starting CI build.

artem-lunarg commented 2 weeks ago

I'd like to point out that the original code is correct. The suggested change is more common though. C++ allows to bind rvalues to const reference. This often looks unusual but the reference will stay alive.

https://stackoverflow.com/questions/11560339/returning-temporary-object-and-binding-to-const-reference

kocdemir commented 2 weeks ago

Right, it should be working fine but I somehow experienced a crash on the usage of the string built this way on MacOS arm64 with the distributed SDK binaries, in an app with multiple vulkan instances spawned. I can debug a bit more if it happens again to see if there are some other underlying issues, but I believe not having references fixed the issue and makes the code more readable as well. Thanks

ci-tester-lunarg commented 2 weeks ago

Author kocdemir not on autobuild list. Waiting for curator authorization before starting CI build.