From da11a9dda32e3588250b29862baa5cea25b8b67b Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 28 Apr 2015 23:02:49 -0400 Subject: [PATCH] cmd/internal/ld, runtime: unify stack reservation in PE header and runtime With 128KB stack reservation, on 32-bit Windows, the maximum number threads is ~9000. The original 65535-byte stack commit is causing problem on Windows XP where it makes the stack reservation to be 1MB despite the fact that the runtime specified 128KB. While we're at here, also fix the extra spacings in the unable to create more OS thread error message: println will insert a space between each argument. See #9457 for more information. Change-Id: I3a82f7d9717d3d55211b6eb1c34b00b0eaad83ed Reviewed-on: https://go-review.googlesource.com/2237 Reviewed-by: Alex Brainman Run-TryBot: Minux Ma --- src/cmd/internal/ld/pe.go | 11 ++++++----- src/runtime/os1_windows.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cmd/internal/ld/pe.go b/src/cmd/internal/ld/pe.go index a71d2d0599..f7a45fd338 100644 --- a/src/cmd/internal/ld/pe.go +++ b/src/cmd/internal/ld/pe.go @@ -1225,12 +1225,13 @@ func Asmbpe() { // 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 as well. + // change STACKSIZE in runtime/cgo/gcc_windows_{386,amd64}.c and correspondent + // CreateThread parameter in runtime.newosproc as well. if !iscgo { - oh64.SizeOfStackReserve = 0x00010000 - oh.SizeOfStackReserve = 0x00010000 - oh64.SizeOfStackCommit = 0x0000ffff - oh.SizeOfStackCommit = 0x0000ffff + oh64.SizeOfStackReserve = 0x00020000 + oh.SizeOfStackReserve = 0x00020000 + oh64.SizeOfStackCommit = 0x00001000 + oh.SizeOfStackCommit = 0x00001000 } else { oh64.SizeOfStackReserve = 0x00200000 oh.SizeOfStackReserve = 0x00100000 diff --git a/src/runtime/os1_windows.go b/src/runtime/os1_windows.go index 2b9739fca3..5719b320f5 100644 --- a/src/runtime/os1_windows.go +++ b/src/runtime/os1_windows.go @@ -282,7 +282,7 @@ func newosproc(mp *m, stk unsafe.Pointer) { funcPC(tstart_stdcall), uintptr(unsafe.Pointer(mp)), _STACK_SIZE_PARAM_IS_A_RESERVATION, 0) if thandle == 0 { - println("runtime: failed to create new OS thread (have ", mcount(), " already; errno=", getlasterror(), ")") + print("runtime: failed to create new OS thread (have ", mcount(), " already; errno=", getlasterror(), ")\n") throw("runtime.newosproc") } } -- 2.50.0