summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilent <zdanio95@gmail.com>2019-11-30 19:22:39 +0100
committerRick Gibbed <rick@gibbed.us>2019-11-30 20:08:30 -0600
commitc5db959154d1e9db014fb646bc0b9c1b660a3587 (patch)
tree67f7ca345d7a2bcdb9950b9f71e78d75e2276aeb
parent728531eff7b3af41fa85685185334a0da1160d4f (diff)
[Kernel] Retain handles and not objects in XThread
This fixes cases introduced by 52e836d0f81e752ba368717e68773b591adfa9cf where thread handles get closed before the thread finishes. Handle was assumed to be alive there, which was not true as threads self-referenced only their objects, not their handles. Affected games: Payday 2 Demo
-rw-r--r--src/xenia/kernel/xthread.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/xenia/kernel/xthread.cc b/src/xenia/kernel/xthread.cc
index 7ba7db2eb..a1e6007a2 100644
--- a/src/xenia/kernel/xthread.cc
+++ b/src/xenia/kernel/xthread.cc
@@ -364,7 +364,7 @@ X_STATUS XThread::Create() {
InitializeGuestObject();
// Always retain when starting - the thread owns itself until exited.
- Retain();
+ RetainHandle();
xe::threading::Thread::CreationParameters params;
params.stack_size = 16 * 1024 * 1024; // Allocate a big host stack.
@@ -405,7 +405,7 @@ X_STATUS XThread::Create() {
xe::Profiler::ThreadExit();
// Release the self-reference to the thread.
- Release();
+ ReleaseHandle();
});
if (!thread_) {
@@ -464,7 +464,7 @@ X_STATUS XThread::Exit(int exit_code) {
xe::Profiler::ThreadExit();
running_ = false;
- Release();
+ ReleaseHandle();
// NOTE: this does not return!
xe::threading::Thread::Exit(exit_code);
@@ -484,11 +484,11 @@ X_STATUS XThread::Terminate(int exit_code) {
running_ = false;
if (XThread::IsInThread(this)) {
- Release();
+ ReleaseHandle();
xe::threading::Thread::Exit(exit_code);
} else {
thread_->Terminate(exit_code);
- Release();
+ ReleaseHandle();
}
return X_STATUS_SUCCESS;
@@ -991,7 +991,7 @@ object_ref<XThread> XThread::Restore(KernelState* kernel_state,
context->vscr_sat = state.context.vscr_sat;
// Always retain when starting - the thread owns itself until exited.
- thread->Retain();
+ thread->RetainHandle();
xe::threading::Thread::CreationParameters params;
params.create_suspended = true; // Not done restoring yet.
@@ -1033,7 +1033,7 @@ object_ref<XThread> XThread::Restore(KernelState* kernel_state,
xe::Profiler::ThreadExit();
// Release the self-reference to the thread.
- thread->Release();
+ thread->ReleaseHandle();
});
// Notify processor we were recreated.