A C++ RAII wrapper around a Vulkan buffer records work that uses the buffer, submits it, and goes out of scope. Its destructor calls vkDestroyBuffer right there. The submitted commands that refer to the buffer are still executing.
That call is invalid. Vulkan requires every submitted command referring to the buffer to have completed execution before the buffer is destroyed. Scope exit only shows that the host is finished with the wrapper. It shows nothing about the GPU.
My first idea is to move the wrapper into a frame retirement list at submission and destroy it only after completion of that submission is known. What I keep going back and forth on is where the move belongs. Inside the submit call? In whatever owns the frame? And calling it a frame list doesn't answer when an entry is actually allowed to go.