This is my hack, i make some objects NULL leaking memory on exit:
Code: Select all
src/c_cmds.cpp | 10 ++++++++++
src/scripting/vm/vmframe.cpp | 11 +++++++++++
src/win32/st_start.cpp | 8 ++++++++
3 files changed, 29 insertions(+)
diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp
index 8e8612dec..488148a60 100644
--- a/src/c_cmds.cpp
+++ b/src/c_cmds.cpp
@@ -77,6 +77,10 @@
extern FILE *Logfile;
extern bool insave;
+#ifdef __MINGW32__
+extern bool exiting; // for MinGW
+#endif
+
CVAR (Bool, sv_cheats, false, CVAR_SERVERINFO | CVAR_LATCH)
CVAR (Bool, sv_unlimited_pickup, false, CVAR_SERVERINFO)
@@ -100,11 +104,17 @@ bool CheckCheatmode (bool printmsg)
CCMD (quit)
{
+#ifdef __MINGW32__
+ exiting = true;
+#endif
if (!insave) exit (0);
}
CCMD (exit)
{
+#ifdef __MINGW32__
+ exiting = true;
+#endif
if (!insave) exit (0);
}
diff --git a/src/scripting/vm/vmframe.cpp b/src/scripting/vm/vmframe.cpp
index 69a6febbf..8d8c26e1a 100644
--- a/src/scripting/vm/vmframe.cpp
+++ b/src/scripting/vm/vmframe.cpp
@@ -41,6 +41,10 @@
#include "vmintern.h"
#include "types.h"
+#ifdef __MINGW32__
+extern bool exiting; // for MinGW
+#endif
+
cycle_t VMCycles[10];
int VMCalls[10];
@@ -243,6 +247,13 @@ VMFrameStack::VMFrameStack()
VMFrameStack::~VMFrameStack()
{
+#ifdef __MINGW32__
+ if (exiting) // hack hack
+ {
+ Blocks = NULL;
+ UnusedBlocks = NULL;
+ }
+#endif
while (PopFrame() != NULL)
{ }
if (Blocks != NULL)
diff --git a/src/win32/st_start.cpp b/src/win32/st_start.cpp
index aa0ce9a03..e6bd46e92 100644
--- a/src/win32/st_start.cpp
+++ b/src/win32/st_start.cpp
@@ -119,6 +119,10 @@
// TYPES -------------------------------------------------------------------
+#ifdef __MINGW32__
+bool exiting = false; // for MinGW
+#endif
+
class FBasicStartupScreen : public FStartupScreen
{
public:
@@ -1093,6 +1097,10 @@ void FStrifeStartupScreen::DrawStuff(int old_laser, int new_laser)
void ST_Endoom()
{
+#ifdef __MINGW32__
+ exiting = true;
+#endif
+
if (showendoom == 0) exit(0);
if (gameinfo.Endoom.Len() == 0)
This is what happens when i keep the variable thread_local:
Code: Select all
#4 0x0042ca38 in ST_Endoom () at C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100
C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100:32931:beg:0x42ca38
In (anonymous namespace)::run() () ()
In msvcrt!_flushall () (C:\Windows\system32\msvcrt.dll)
In msvcrt!.p.iob () (C:\Windows\system32\msvcrt.dll)
In ntdll!RtlDecodePointer () (C:\Windows\SYSTEM32\ntdll.dll)
In msvcrt!.p.iob () (C:\Windows\system32\msvcrt.dll)
In msvcrt!_flushall () (C:\Windows\system32\msvcrt.dll)
In msvcrt!.p.iob () (C:\Windows\system32\msvcrt.dll)
In ntdll!RtlDecodePointer () (C:\Windows\SYSTEM32\ntdll.dll)
In msvcrt!.p.iob () (C:\Windows\system32\msvcrt.dll)
In msvcrt!_flushall () (C:\Windows\system32\msvcrt.dll)
In msvcrt!_CallMemberFunction0 () (C:\Windows\system32\msvcrt.dll)
#2 0x0042ca38 in ST_Endoom () at C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100
C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100:32931:beg:0x42ca38
At C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100
#2 0x0042ca38 in ST_Endoom () at C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100
C:\DEV\vsqzdoom\src\win32\st_start.cpp:1100:32931:beg:0x42ca38
In RaiseException () (C:\Windows\system32\KernelBase.dll)
[Inferior 1 (process 4196) exited with code 0377]
So i think this can be closed now as not ZDoom.