From 09dd3a87299c20b7c27da52f8f866f7ea9b7098f Mon Sep 17 00:00:00 2001 From: Scott Romero <24445312+AMZN-ScottR@users.noreply.github.com> Date: Fri, 21 Jan 2022 09:06:14 -0800 Subject: [PATCH] [development] patch fix for launcher exit crash (#7050) The launcher will crash on exit due to an access violation when clearing the BudgetTracker after CrySystem is unloaded. This is from a recent change to how the budget pointers are tracked making the BudgetTracker responsible for clearing them so the system can be re-entrant. Unfortunately, an assumption was made that all modules that use Budgets are managed by the ComponentApplication so they can be cleared prior to being unloaded. This is a patch to manually reset the BudgetTracker prior to unloading CrySystem until the legacy system can be removed (or converted to an AZ-like module). Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com --- Code/LauncherUnified/Launcher.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Code/LauncherUnified/Launcher.cpp b/Code/LauncherUnified/Launcher.cpp index 9dfd6213c4..7b681c5208 100644 --- a/Code/LauncherUnified/Launcher.cpp +++ b/Code/LauncherUnified/Launcher.cpp @@ -10,14 +10,17 @@ #include #include +#include +#include #include +#include #include #include #include -#include #include #include #include + #include #include #include @@ -571,6 +574,17 @@ namespace O3DELauncher } #if !defined(AZ_MONOLITHIC_BUILD) + + #if !defined(_RELEASE) + // until CrySystem can be removed (or made to be managed by the component application), + // we need to manually clear the BudgetTracker before CrySystem is unloaded so the Budget + // pointer(s) it has references to are cleared properly + if (auto budgetTracker = AZ::Interface::Get(); budgetTracker) + { + budgetTracker->Reset(); + } + #endif // !defined(_RELEASE) + delete systemInitParams.pSystem; crySystemLibrary.reset(nullptr); #endif // !defined(AZ_MONOLITHIC_BUILD)