Fixes a crash in PaintTool SAI when allocating more than 2GB of memory.
Signed-off-by: Elaine Lefler <elaineclefler(a)gmail.com>
---
v2: Removed todo_wine from appropriate tests, along with a note about
why that test is broken on win32.
---
dlls/ntdll/tests/info.c | 16 ++++++++++++----
dlls/ntdll/unix/virtual.c | 6 +++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 89503093b17..4f2441d95d8 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1839,8 +1839,13 @@ static void test_query_process_vm(void)
ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %Iu/%Iu\n", pvi.PrivateUsage, pvi.PagefileUsage );
if (winetest_debug > 1)
dump_vm_counters("VM counters after VirtualAlloc", &pvi);
- todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
- "Expected to be greater than %Iu, got %Iu\n", prev_size + alloc_size, pvi.VirtualSize);
+#ifndef _WIN64
+ /* Fails on win32 due to mapping in reserved areas. The unused regions
+ * should be subtracted from VirtualSize for it to succeed. */
+ todo_wine
+#endif
+ ok( pvi.VirtualSize >= prev_size + alloc_size,
+ "Expected to be at least %Iu, got %Iu\n", prev_size + alloc_size, pvi.VirtualSize);
VirtualFree( ptr, 0, MEM_RELEASE);
status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
@@ -1856,8 +1861,11 @@ static void test_query_process_vm(void)
ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %Iu/%Iu\n", pvi.PrivateUsage, pvi.PagefileUsage );
if (winetest_debug > 1)
dump_vm_counters("VM counters after VirtualAlloc(MEM_RESERVE)", &pvi);
- todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
- "Expected to be greater than %Iu, got %Iu\n", prev_size + alloc_size, pvi.VirtualSize);
+#ifndef _WIN64
+ todo_wine
+#endif
+ ok( pvi.VirtualSize >= prev_size + alloc_size,
+ "Expected to be at least %Iu, got %Iu\n", prev_size + alloc_size, pvi.VirtualSize);
prev_size = pvi.VirtualSize;
ptr = VirtualAlloc(ptr, alloc_size, MEM_COMMIT, PAGE_READWRITE);
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 02478cceb06..93a4495adb9 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1917,7 +1917,11 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
alloc.top_down = top_down;
alloc.limit = (void*)(get_zero_bits_mask( zero_bits ) & (UINT_PTR)user_space_limit);
- if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down ))
+ if (
+#ifdef _WIN64
+ size < 2 * 1024 * 1024 &&
+#endif
+ mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down ))
{
ptr = alloc.result;
TRACE( "got mem in reserved area %p-%p\n", ptr, (char *)ptr + size );
--
2.32.0 (Apple Git-132)