Skip to content

Commit

Permalink
Make sure samples' session is released before other global destructors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rshest authored and facebook-github-bot committed Oct 24, 2023
1 parent 2b0e793 commit 96f8080
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions shell/windows/vulkan/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 96f8080

Please sign in to comment.