From e06889069c82aabafc5df3181191754ad6c25c6e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 14 Oct 2013 22:05:33 -0700 Subject: [PATCH] Don't use the destructor to free thread stacks. If we do, kernelObjects.clear() will trash perfectly good memory on loading a state. I guess it also makes shutdown slower. Fixes #4186. --- Core/HLE/sceKernelThread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index d594443130..3602fdbce0 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -487,7 +487,8 @@ public: currentStack.start = 0; } - ~Thread() + // Can't use a destructor since savestates will call that too. + void Cleanup() { // Callbacks are automatically deleted when their owning thread is deleted. for (auto it = callbacks.begin(), end = callbacks.end(); it != end; ++it) @@ -1798,6 +1799,8 @@ u32 __KernelDeleteThread(SceUID threadID, int exitStatus, const char *reason) if (callback && callback->nc.notifyCount != 0) readyCallbacksCount--; } + + t->Cleanup(); } return kernelObjects.Destroy(threadID);