[PATCH 1/2] kernel32: Allocate at least 1MB of stack space in CreateFiberEx().

Zebediah Figura zfigura at codeweavers.com
Tue Jun 11 18:09:38 CDT 2019


Planet Coaster allocates 128KB of stack (both reserve and commit) but then
tries to use at least one page more. Testing shows that native Windows
always allocates at least 1MB of stack, for both 32-bit and 64-bit programs.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/kernel32/fiber.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/fiber.c b/dlls/kernel32/fiber.c
index 151a6765a8bf..526ae57f2f42 100644
--- a/dlls/kernel32/fiber.c
+++ b/dlls/kernel32/fiber.c
@@ -97,7 +97,8 @@ LPVOID WINAPI CreateFiberEx( SIZE_T stack_commit, SIZE_T stack_reserve, DWORD fl
     }
 
     /* FIXME: should use the thread stack allocation routines here */
-    if (!stack_reserve) stack_reserve = 1024*1024;
+    /* some applications try to use more stack than they allocate */
+    stack_reserve = max(stack_reserve, 1024 * 1024);
     if(!(fiber->stack_allocation = VirtualAlloc( 0, stack_reserve, MEM_COMMIT, PAGE_READWRITE )))
     {
         HeapFree( GetProcessHeap(), 0, fiber );
-- 
2.20.1




More information about the wine-devel mailing list