From 5498ebd8c0aaa651ce6823cccdf572a3f551deba Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 10 Jul 2020 14:39:20 +0300 Subject: [PATCH] ntdll: Stop search on mmap() error in try_map_free_area(). The anon mmap errors do not depend on start address hint. Ignoring them makes the search take incredible time until it fails. Signed-off-by: Paul Gofman Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/virtual.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 4e5b1acf0bc..20bf5ff066a 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -1009,8 +1009,14 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, return start; TRACE( "Found free area is already mapped, start %p.\n", start ); - if (ptr != (void *)-1) - munmap( ptr, size ); + if (ptr == (void *)-1) + { + ERR( "wine_anon_mmap() error %s, range %p-%p, unix_prot %#x.\n", + strerror(errno), start, (char *)start + size, unix_prot ); + return NULL; + } + + munmap( ptr, size ); if ((step > 0 && (char *)end - (char *)start < step) || (step < 0 && (char *)start - (char *)base < -step) ||