From 20fb20d7f66657cdac37789fbec977f569d027aa Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Sun, 6 Dec 2015 17:45:40 -0600 Subject: [PATCH] Hold the global lock while restoring from a file. --- src/xenia/emulator.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 057741d5f..edce53b0b 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -347,6 +347,8 @@ bool Emulator::SaveToFile(const std::wstring& path) { ByteStream stream(map->data(), map->size()); stream.Write('XSAV'); + // It's important we don't hold the global lock here! XThreads need to step + // forward (possibly through guarded regions) without worry! kernel_state_->Save(&stream); memory_->Save(&stream); map->Close(stream.offset()); @@ -356,6 +358,8 @@ bool Emulator::SaveToFile(const std::wstring& path) { } bool Emulator::RestoreFromFile(const std::wstring& path) { + auto lock = global_critical_region::AcquireDirect(); + // Restore the emulator state from a file auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite); if (!map) {