diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index 16ce7bd016..00fbb170b6 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -1217,12 +1217,17 @@ func Asmbpe() { // larger size, as verified with VMMap. // Go code would be OK with 64k stacks, but we need larger stacks for cgo. - // That default stack reserve size affects only the main thread, - // for other threads we specify stack size in runtime explicitly + // + // The default stack reserve size affects only the main + // thread, ctrlhandler thread, and profileloop thread. For + // these, it must be greater than the stack size assumed by + // externalthreadhandler. + // + // For other threads we specify stack size in runtime explicitly // (runtime knows whether cgo is enabled or not). - // If you change stack reserve sizes here, - // change STACKSIZE in runtime/cgo/gcc_windows_{386,amd64}.c and correspondent - // CreateThread parameter in runtime.newosproc as well. + // For these, the reserve must match STACKSIZE in + // runtime/cgo/gcc_windows_{386,amd64}.c and the correspondent + // CreateThread parameter in runtime.newosproc. if !iscgo { oh64.SizeOfStackReserve = 0x00020000 oh.SizeOfStackReserve = 0x00020000 diff --git a/src/runtime/sys_windows_386.s b/src/runtime/sys_windows_386.s index e5fe88afd8..55cdcf407f 100644 --- a/src/runtime/sys_windows_386.s +++ b/src/runtime/sys_windows_386.s @@ -206,7 +206,8 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 CALL runtime·memclr(SB) // smashes AX,BX,CX LEAL g__size(SP), BX MOVL BX, g_m(SP) - LEAL -8192(SP), CX + + LEAL -32768(SP), CX // must be less than SizeOfStackReserve set by linker MOVL CX, (g_stack+stack_lo)(SP) ADDL $const__StackGuard, CX MOVL CX, g_stackguard0(SP) diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index b15eacbf32..caa18e68e9 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -243,7 +243,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 LEAQ g__size(SP), BX MOVQ BX, g_m(SP) - LEAQ -8192(SP), CX + LEAQ -32768(SP), CX // must be less than SizeOfStackReserve set by linker MOVQ CX, (g_stack+stack_lo)(SP) ADDQ $const__StackGuard, CX MOVQ CX, g_stackguard0(SP)