summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar lat9nq2022-04-01 18:32:20 -0400
committerGravatar lat9nq2022-04-03 21:47:57 -0400
commit5b5a1b7fa7470bd32b5481ae6a6cf5f4b07c80c8 (patch)
treeb5531cba3ca905a6561be6d77caec087183fe177 /src/core/hle/kernel/kernel.cpp
parentk_scheduler_lock: Fix data race (diff)
downloadyuzu-5b5a1b7fa7470bd32b5481ae6a6cf5f4b07c80c8.tar.gz
yuzu-5b5a1b7fa7470bd32b5481ae6a6cf5f4b07c80c8.tar.xz
yuzu-5b5a1b7fa7470bd32b5481ae6a6cf5f4b07c80c8.zip
kernel: Fix current_process race
TSan reported a race at :258 and :803, so make current_process an atomic pointer.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 34da7c23b..caa91a509 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -84,7 +84,7 @@ struct KernelCore::Impl {
84 84
85 void InitializeCores() { 85 void InitializeCores() {
86 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { 86 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
87 cores[core_id].Initialize(current_process->Is64BitProcess()); 87 cores[core_id].Initialize((*current_process).Is64BitProcess());
88 system.Memory().SetCurrentPageTable(*current_process, core_id); 88 system.Memory().SetCurrentPageTable(*current_process, core_id);
89 } 89 }
90 } 90 }
@@ -167,11 +167,11 @@ struct KernelCore::Impl {
167 167
168 // Shutdown all processes. 168 // Shutdown all processes.
169 if (current_process) { 169 if (current_process) {
170 current_process->Finalize(); 170 (*current_process).Finalize();
171 // current_process->Close(); 171 // current_process->Close();
172 // TODO: The current process should be destroyed based on accurate ref counting after 172 // TODO: The current process should be destroyed based on accurate ref counting after
173 // calling Close(). Adding a manual Destroy() call instead to avoid a memory leak. 173 // calling Close(). Adding a manual Destroy() call instead to avoid a memory leak.
174 current_process->Destroy(); 174 (*current_process).Destroy();
175 current_process = nullptr; 175 current_process = nullptr;
176 } 176 }
177 177
@@ -697,7 +697,7 @@ struct KernelCore::Impl {
697 697
698 // Lists all processes that exist in the current session. 698 // Lists all processes that exist in the current session.
699 std::vector<KProcess*> process_list; 699 std::vector<KProcess*> process_list;
700 KProcess* current_process{}; 700 std::atomic<KProcess*> current_process{};
701 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context; 701 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
702 Kernel::TimeManager time_manager; 702 Kernel::TimeManager time_manager;
703 703