From 393a642c2292b328017fd7f527e7e2dd738b58ae Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sat, 30 Jan 2021 10:08:08 -0800 Subject: [PATCH] Increase Windows stack size (#32) We're now using the same values CMD.EXE uses. --- ape/ape.S | 4 ++-- libc/runtime/winmain.greg.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ape/ape.S b/ape/ape.S index bdcfa7d1d..0463e0499 100644 --- a/ape/ape.S +++ b/ape/ape.S @@ -783,8 +783,8 @@ ape.pe: .ascin "PE",4 .long 0 # Checksum .short v_ntsubsystem # Subsystem: 0=Neutral,2=GUI,3=Console .short .LDLLEXE # DllCharacteristics - .quad 0x0000000000020000 # StackReserve - .quad 0x0000000000020000 # StackCommit + .quad 0x0000000000100000 # StackReserve + .quad 0x00000000000fc000 # StackCommit .quad 0 # HeapReserve .quad 0 # HeapCommit .long 0 # LoaderFlags diff --git a/libc/runtime/winmain.greg.c b/libc/runtime/winmain.greg.c index 577ae19bb..1e6cbd77d 100644 --- a/libc/runtime/winmain.greg.c +++ b/libc/runtime/winmain.greg.c @@ -49,6 +49,8 @@ * TODO: How can we ensure we never overlap with KERNEL32.DLL? */ +#define WINSTACK 0x100000 + struct WinArgs { char *argv[4096]; char *envp[4096]; @@ -107,7 +109,7 @@ static textwindows wontreturn void WinMainNew(void) { NormalizeCmdExe(); *(/*unconst*/ int *)&__hostos = WINDOWS; addr = NtGetVersion() < kNtVersionWindows10 ? 0xff00000 : 0x777000000000; - size = ROUNDUP(STACKSIZE + sizeof(struct WinArgs), FRAMESIZE); + size = ROUNDUP(WINSTACK + sizeof(struct WinArgs), FRAMESIZE); _mmi.p[0].h = __mmap$nt((char *)addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0) .maphandle; @@ -128,7 +130,7 @@ static textwindows wontreturn void WinMainNew(void) { FreeEnvironmentStrings(env16); auxv[0][0] = pushpop(0L); auxv[0][1] = pushpop(0L); - _jmpstack((char *)addr + STACKSIZE, _executive, count, wa->argv, wa->envp, + _jmpstack((char *)addr + WINSTACK, _executive, count, wa->argv, wa->envp, auxv); }