From 160cdda90285426ef9c12c5f106bcfd6c2746fc9 Mon Sep 17 00:00:00 2001 From: MaranBr Date: Thu, 14 Aug 2025 13:10:15 -0400 Subject: [PATCH 1/2] Ensure all kernel objects exist before destroying them and avoid infinite loop between Open() and Close() functions. --- src/core/hle/kernel/k_auto_object.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index 8d4e0df44f..0e21d16354 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -153,12 +153,15 @@ public: // Atomically decrement the reference count, not allowing it to become negative. u32 cur_ref_count = m_ref_count.load(std::memory_order_acquire); do { + if (cur_ref_count == 0) { + return; + } ASSERT(cur_ref_count > 0); } while (!m_ref_count.compare_exchange_weak(cur_ref_count, cur_ref_count - 1, std::memory_order_acq_rel)); - // If ref count hits zero, destroy the object. - if (cur_ref_count - 1 == 0) { + // If ref count hits 1, destroy the object. + if (cur_ref_count == 1) { KernelCore& kernel = m_kernel; this->Destroy(); KAutoObject::UnregisterWithKernel(kernel, this); -- 2.39.5 From 8633db64b50947443df8fc469f56027cd4cf7012 Mon Sep 17 00:00:00 2001 From: MaranBr Date: Thu, 14 Aug 2025 13:20:30 -0400 Subject: [PATCH 2/2] Fix headers --- src/core/hle/kernel/k_auto_object.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index 0e21d16354..c61b10625a 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -1,5 +1,8 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later #pragma once -- 2.39.5