瀏覽代碼

Fix flush action from multiple threads regression (#3311)

If two or more threads encounter a region of memory where a read action has been registered, then they must _both_ wait on the data.

Clearing the action before it completed was causing the null check above to fail, so the action would only be run on the first thread, and the second would end up continuing without waiting. Depending on what the game does, this could be disasterous.

This fixes a regression introduced by #3302 with Pokemon Legends Arceus, and possibly Catherine. There are likely other affected games. What is fixed in that PR should still be fixed.
riperiperi 4 年之前
父節點
當前提交
4a892fbdc9
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      Ryujinx.Memory/Tracking/RegionHandle.cs

+ 4 - 2
Ryujinx.Memory/Tracking/RegionHandle.cs

@@ -144,9 +144,11 @@ namespace Ryujinx.Memory.Tracking
                 {
                     lock (_preActionLock)
                     {
-                        RegionSignal action = Interlocked.Exchange(ref _preAction, null);
+                        _preAction?.Invoke(address, size);
 
-                        action?.Invoke(address, size);
+                        // The action is removed after it returns, to ensure that the null check above succeeds when
+                        // it's still in progress rather than continuing and possibly missing a required data flush.
+                        Interlocked.Exchange(ref _preAction, null);
                     }
                 }
                 finally