mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-21 00:42:01 +00:00
Fix mapping leaks caused by UnmapView not working on Linux (#3650)
* Add test for UnmapView mapping leaks * Throw when UnmapView fails on Linux * Fix UnmapView * Remove throw
This commit is contained in:
parent
8d41402fa6
commit
7d26e4ac7b
2 changed files with 27 additions and 1 deletions
|
@ -92,5 +92,31 @@ namespace Ryujinx.Memory.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_AliasMapLeak()
|
||||||
|
{
|
||||||
|
if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong pageSize = 4096;
|
||||||
|
ulong size = 100000 * pageSize; // The mappings limit on Linux is usually around 65K, so let's make sure we are above that.
|
||||||
|
|
||||||
|
using MemoryBlock backing = new MemoryBlock(pageSize, MemoryAllocationFlags.Mirrorable);
|
||||||
|
using MemoryBlock toAlias = new MemoryBlock(size, MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible);
|
||||||
|
|
||||||
|
for (ulong offset = 0; offset < size; offset += pageSize)
|
||||||
|
{
|
||||||
|
toAlias.MapView(backing, 0, offset, pageSize);
|
||||||
|
|
||||||
|
toAlias.Write(offset, 0xbadc0de);
|
||||||
|
Assert.AreEqual(0xbadc0de, backing.Read<int>(0));
|
||||||
|
|
||||||
|
toAlias.UnmapView(backing, offset, pageSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -177,7 +177,7 @@ namespace Ryujinx.Memory
|
||||||
|
|
||||||
public static void UnmapView(IntPtr location, ulong size)
|
public static void UnmapView(IntPtr location, ulong size)
|
||||||
{
|
{
|
||||||
mmap(location, size, MmapProts.PROT_NONE, MmapFlags.MAP_FIXED, -1, 0);
|
mmap(location, size, MmapProts.PROT_NONE, MmapFlags.MAP_FIXED | MmapFlags.MAP_PRIVATE | MmapFlags.MAP_ANONYMOUS | MmapFlags.MAP_NORESERVE, -1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue