Ensure we wait for the test thread to be dead on PartialUnmap

This commit is contained in:
Mary 2022-12-02 09:57:45 +01:00 committed by TSR Berry
parent 1725e03bda
commit 3fe5a709bb
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2

View file

@ -78,11 +78,13 @@ namespace Ryujinx.Tests.Memory
ref var state = ref PartialUnmapState.GetRef(); ref var state = ref PartialUnmapState.GetRef();
Thread testThread = null;
bool shouldAccess = true;
try try
{ {
// Globally reset the struct for handling partial unmap races. // Globally reset the struct for handling partial unmap races.
PartialUnmapState.Reset(); PartialUnmapState.Reset();
bool shouldAccess = true;
bool error = false; bool error = false;
// Create a large mapping. // Create a large mapping.
@ -93,8 +95,6 @@ namespace Ryujinx.Tests.Memory
memory.Reprotect(0, vaSize, MemoryPermission.Read); memory.Reprotect(0, vaSize, MemoryPermission.Read);
} }
Thread testThread;
if (readOnly) if (readOnly)
{ {
// Write a value to the physical memory, then try to read it repeately from virtual. // Write a value to the physical memory, then try to read it repeately from virtual.
@ -193,6 +193,10 @@ namespace Ryujinx.Tests.Memory
} }
finally finally
{ {
// In case something failed, we want to ensure the test thread is dead before disposing of the memory.
shouldAccess = false;
testThread?.Join();
exceptionHandler.Dispose(); exceptionHandler.Dispose();
unusedMainMemory.Dispose(); unusedMainMemory.Dispose();
memory.Dispose(); memory.Dispose();