Skip to content

Commit 393a642

Browse files
committed
Increase Windows stack size (#32)
We're now using the same values CMD.EXE uses.
1 parent 9517364 commit 393a642

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ape/ape.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ ape.pe: .ascin "PE",4
783783
.long 0 # Checksum
784784
.short v_ntsubsystem # Subsystem: 0=Neutral,2=GUI,3=Console
785785
.short .LDLLEXE # DllCharacteristics
786-
.quad 0x0000000000020000 # StackReserve
787-
.quad 0x0000000000020000 # StackCommit
786+
.quad 0x0000000000100000 # StackReserve
787+
.quad 0x00000000000fc000 # StackCommit
788788
.quad 0 # HeapReserve
789789
.quad 0 # HeapCommit
790790
.long 0 # LoaderFlags

libc/runtime/winmain.greg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
* TODO: How can we ensure we never overlap with KERNEL32.DLL?
5050
*/
5151

52+
#define WINSTACK 0x100000
53+
5254
struct WinArgs {
5355
char *argv[4096];
5456
char *envp[4096];
@@ -107,7 +109,7 @@ static textwindows wontreturn void WinMainNew(void) {
107109
NormalizeCmdExe();
108110
*(/*unconst*/ int *)&__hostos = WINDOWS;
109111
addr = NtGetVersion() < kNtVersionWindows10 ? 0xff00000 : 0x777000000000;
110-
size = ROUNDUP(STACKSIZE + sizeof(struct WinArgs), FRAMESIZE);
112+
size = ROUNDUP(WINSTACK + sizeof(struct WinArgs), FRAMESIZE);
111113
_mmi.p[0].h =
112114
__mmap$nt((char *)addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0)
113115
.maphandle;
@@ -128,7 +130,7 @@ static textwindows wontreturn void WinMainNew(void) {
128130
FreeEnvironmentStrings(env16);
129131
auxv[0][0] = pushpop(0L);
130132
auxv[0][1] = pushpop(0L);
131-
_jmpstack((char *)addr + STACKSIZE, _executive, count, wa->argv, wa->envp,
133+
_jmpstack((char *)addr + WINSTACK, _executive, count, wa->argv, wa->envp,
132134
auxv);
133135
}
134136

0 commit comments

Comments
 (0)