From 82986c6eec0503203604f2df96bbba813265a4f7 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Sun, 5 Jul 2015 16:22:45 -0500 Subject: [PATCH] Use TerminateTitle rather than relying on XamLoader* being called from the main thread. --- src/xenia/kernel/kernel_state.cc | 3 +++ src/xenia/kernel/xam_info.cc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 15f10e818..ed71209da 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -312,6 +312,7 @@ void KernelState::TerminateTitle(bool from_guest_thread) { if (from_guest_thread && XThread::IsInThread(thread)) { // Don't terminate ourselves. + ++it; continue; } @@ -336,6 +337,8 @@ void KernelState::TerminateTitle(bool from_guest_thread) { user_modules_.clear(); if (from_guest_thread) { + threads_by_id_.erase(XThread::GetCurrentThread()->thread_id()); + // Now commit suicide (using Terminate, because we can't call into guest // code anymore) // Also, manually invoke the lock guard's destructor, because Terminate diff --git a/src/xenia/kernel/xam_info.cc b/src/xenia/kernel/xam_info.cc index 8fbacd9ad..1042417df 100644 --- a/src/xenia/kernel/xam_info.cc +++ b/src/xenia/kernel/xam_info.cc @@ -170,13 +170,13 @@ void XamLoaderLaunchTitle(lpstring_t raw_name, dword_t flags) { } // This function does not return. - XThread::GetCurrentThread()->Exit(0); + kernel_state()->TerminateTitle(true); } DECLARE_XAM_EXPORT(XamLoaderLaunchTitle, ExportTag::kSketchy); void XamLoaderTerminateTitle() { // This function does not return. - XThread::GetCurrentThread()->Exit(0); + kernel_state()->TerminateTitle(true); } DECLARE_XAM_EXPORT(XamLoaderTerminateTitle, ExportTag::kSketchy);