Skip to content
Permalink
Browse files

- added explicit clearing of global VM stask

When exception is thrown from JITed code, VM stask isn't cleared during unwinding
It needs to be clear explicitly to avoid memory leaks and references to destructed objects on shutdown

https://forum.zdoom.org/viewtopic.php?t=66172
  • Loading branch information...
alexey-lysiuk committed Oct 21, 2019
1 parent ed337b3 commit 994960627bf75bf7a380f0540a60966700146dfd
Showing with 12 additions and 0 deletions.
  1. +1 −0 src/d_main.cpp
  2. +1 −0 src/playsim/dthinker.cpp
  3. +2 −0 src/scripting/vm/vm.h
  4. +8 −0 src/scripting/vm/vmframe.cpp
@@ -984,6 +984,7 @@ void D_ErrorCleanup ()
}
if (gamestate == GS_INTERMISSION) gamestate = GS_DEMOSCREEN;
insave = false;
ClearGlobalVMStack();
}

//==========================================================================
@@ -250,6 +250,7 @@ void FThinkerCollection::DestroyAllThinkers()
GC::FullGC();
if (error)
{
ClearGlobalVMStack();
I_Error("DestroyAllThinkers failed");
}
}
@@ -110,6 +110,8 @@ class CVMAbortException : public CDoomError
void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...);
void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...);

void ClearGlobalVMStack();

struct VMReturn
{
void *Location;
@@ -715,6 +715,14 @@ void ThrowVMException(VMException *x)
#endif


void ClearGlobalVMStack()
{
while (GlobalVMStack.PopFrame() != nullptr)
{
}
}


ADD_STAT(VM)
{
double added = 0;

0 comments on commit 9949606

Please sign in to comment.
You can’t perform that action at this time.