diff options
author | bunnei <bunneidev@gmail.com> | 2022-03-12 03:06:57 -0800 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2022-03-14 18:14:54 -0700 |
commit | 5f3e77d93e93dded50b2fcf9f67291442197e567 (patch) | |
tree | 760e2cc11ac422fe1b330fd6d3649e77c7699f83 /src/core/hle/kernel/kernel.cpp | |
parent | 82a2463062045c42c2a78946e2a69611f51c04d4 (diff) |
core: hle: kernel: Allocate dummy threads on host thread storage.
- Fixes a crash where on subsequent boots, long-lived host threads would have their dummy threads freed.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 16d3a6cb4f..f9828bc43e 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -283,15 +283,16 @@ struct KernelCore::Impl { // Gets the dummy KThread for the caller, allocating a new one if this is the first time KThread* GetHostDummyThread() { - auto make_thread = [this]() { - KThread* thread = KThread::Create(system.Kernel()); + auto initialize = [this](KThread* thread) { ASSERT(KThread::InitializeDummyThread(thread).IsSuccess()); thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId())); return thread; }; - thread_local KThread* saved_thread = make_thread(); - return saved_thread; + thread_local auto raw_thread = KThread(system.Kernel()); + thread_local auto thread = initialize(&raw_thread); + + return thread; } /// Registers a CPU core thread by allocating a host thread ID for it |