From 83c7ed314e9b58309c090328c35baa0826c9c30e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 9 Oct 2022 16:44:36 +0100 Subject: [PATCH] Setup KThread pthread handle in StartThread Avoids a race with starting the thread and the handle not being set yet --- app/src/main/cpp/skyline/kernel/types/KThread.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/kernel/types/KThread.cpp b/app/src/main/cpp/skyline/kernel/types/KThread.cpp index 7d31bdba..3f4d93fc 100644 --- a/app/src/main/cpp/skyline/kernel/types/KThread.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KThread.cpp @@ -35,6 +35,7 @@ namespace skyline::kernel::type { } void KThread::StartThread() { + pthread = pthread_self(); std::array threadName{}; if (int result{pthread_getname_np(pthread, threadName.data(), threadName.size())}) Logger::Warn("Failed to get the thread name: {}", strerror(result)); @@ -216,12 +217,10 @@ namespace skyline::kernel::type { killed = false; statusCondition.notify_all(); if (self) { - pthread = pthread_self(); lock.unlock(); StartThread(); } else { thread = std::thread(&KThread::StartThread, this); - pthread = thread.native_handle(); } } }