From 96f808091fd545238e68edbcea86176e48412598 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Tue, 24 Oct 2023 11:50:41 -0700 Subject: [PATCH] Make sure samples' session is released before other global destructors Summary: This enforces release of the Session object before exiting from the main app function in shell. This guarantees that whatever graphics resources are held in the Session object, they are released before the call of the other global destructors, one example of the latter being resource trackers. Since the order of the global destructors' calls is not guaranteed, this may cause a situation when a leak tracker is triggered before the resources were released, triggering a false positive assert on exit. Reviewed By: MichaelTay Differential Revision: D50603617 fbshipit-source-id: 33ebe765d3e35e07760732dbdb988e7fd877455a --- shell/windows/vulkan/App.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell/windows/vulkan/App.cpp b/shell/windows/vulkan/App.cpp index 1a2c8e8348..07fb22fbc9 100644 --- a/shell/windows/vulkan/App.cpp +++ b/shell/windows/vulkan/App.cpp @@ -195,5 +195,12 @@ int main(int argc, char* argv[]) { glfwDestroyWindow(vulkanWindow.get()); glfwTerminate(); + // Explicitly destroy all objects before exiting in order to make sure that + // whatever else global destructors may there, will be called after these. One + // example is a graphics resource tracker in the client code, which otherwise + // would not be guaranteed to be called after the graphics resources release. + vulkanShellPlatform_ = nullptr; + vulkanSession_ = nullptr; + return 0; }