Commit da11a9dd authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

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/2237Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
Run-TryBot: Minux Ma <minux@golang.org>
parent edac5d91
......@@ -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
......
......@@ -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")
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment