From 034ddcc092adff4860fd0903777da97bc4ccc7c3 Mon Sep 17 00:00:00 2001 From: Mathias <06mathias6@gmail.com> Date: Tue, 18 Aug 2026 12:13:32 +0200 Subject: [PATCH] fix(vmem): use ConcurrentDictionary for _pageProtections to prevent race corruption (#823) --- src/SharpEmu.Core/Memory/PhysicalVirtualMemory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SharpEmu.Core/Memory/PhysicalVirtualMemory.cs b/src/SharpEmu.Core/Memory/PhysicalVirtualMemory.cs index 4991746c..8c6f8f07 100644 --- a/src/SharpEmu.Core/Memory/PhysicalVirtualMemory.cs +++ b/src/SharpEmu.Core/Memory/PhysicalVirtualMemory.cs @@ -1,6 +1,7 @@ // Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +using System.Collections.Concurrent; using System.Runtime.InteropServices; using SharpEmu.Core.Loader; using SharpEmu.HLE; @@ -18,7 +19,7 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA private readonly object _allocationSearchHintGate = new(); private readonly List _regions = new(); private readonly Dictionary<(ulong DesiredAddress, ulong Alignment, bool Executable), ulong> _allocationSearchHints = new(); - private readonly Dictionary _pageProtections = new(); + private readonly ConcurrentDictionary _pageProtections = new(); private bool _disposed; [ThreadStatic]