From b20deb0752741d70e68832f731608546c1d51e5c Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 17 Mar 2015 09:31:25 +0100 Subject: [PATCH] MTVU: fix linux crash after a shutdown * Lock during the reset * Purge the ring before memory unallocation Close issue #474 --- pcsx2/MTVU.cpp | 2 ++ pcsx2/System.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/pcsx2/MTVU.cpp b/pcsx2/MTVU.cpp index 32dd794fbd..0ed2519743 100644 --- a/pcsx2/MTVU.cpp +++ b/pcsx2/MTVU.cpp @@ -69,6 +69,8 @@ VU_Thread::~VU_Thread() throw() void VU_Thread::Reset() { + ScopedLock lock(mtxBusy); + read_pos = 0; write_pos = 0; write_offset = 0; diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 25d15610a7..1b900fd4c6 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -18,6 +18,7 @@ #include "IopCommon.h" #include "VUmicro.h" #include "newVif.h" +#include "MTVU.h" #include "SamplProf.h" @@ -418,6 +419,12 @@ void SysMainMemory::DecommitAll() Console.WriteLn( Color_Blue, "Decommitting host memory for virtual systems..." ); ConsoleIndentScope indent(1); + // On linux, the MTVU isn't empty and the thread still uses the m_ee/m_vu memory + vu1Thread.WaitVU(); + // The EE thread must be stopped here command mustn't be send + // to the ring. Let's call it an extra safety valve :) + vu1Thread.Reset(); + m_ee.Decommit(); m_iop.Decommit(); m_vu.Decommit();