]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/ld, runtime: unify stack reservation in PE header and runtime
authorShenghou Ma <minux@golang.org>
Wed, 29 Apr 2015 03:02:49 +0000 (23:02 -0400)
committerMinux Ma <minux@golang.org>
Wed, 29 Apr 2015 03:27:10 +0000 (03:27 +0000)
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 <alex.brainman@gmail.com>
Run-TryBot: Minux Ma <minux@golang.org>

src/cmd/internal/ld/pe.go
src/runtime/os1_windows.go

index a71d2d05993766b2bf07d6636183d60831c74332..f7a45fd3381541c1f25bd1e2cf78248ab4e7d93e 100644 (file)
@@ -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
index 2b9739fca3e8c39b8e58799014b353672f534537..5719b320f52953b78ed7c61dbc6aa324e7106c69 100644 (file)
@@ -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")
        }
 }