From 7ac62f42a370c342a29475990798b7db129146da Mon Sep 17 00:00:00 2001 From: Jeff Hutchinson Date: Sat, 20 Nov 2021 19:07:48 -0500 Subject: [PATCH] Fixed a leak with console stack in the interpreter. Issue was pushing a new frame in the global scope. Everytime a global scope was called, 1 ConsoleValue got allocated that was never freed. After 4096 'global scope' function calls, the engine would blow. Also cleans up an extra rogue usage of push/pop with the saver helper. --- Engine/source/console/compiledEval.cpp | 1 - Engine/source/console/console.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 126cf4b01..0b2e66b4b 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -696,7 +696,6 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa { // argc is the local count for eval gEvalState.pushFrame(NULL, NULL, argc); - gCallStack.pushFrame(0); popFrame = true; } else diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index 59fca1874..d9ba1dcff 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -1628,9 +1628,9 @@ static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue a ICallMethod *com = dynamic_cast(object); if(com) { - gCallStack.pushFrame(0); + ConsoleStackFrameSaver saver; + saver.save(); com->callMethodArgList(argc, argv, false); - gCallStack.popFrame(); } }