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 <alex.brainman@gmail.com>
Run-TryBot: Minux Ma <minux@golang.org>
diff --git a/src/cmd/internal/ld/pe.go b/src/cmd/internal/ld/pe.go
index a71d2d0..f7a45fd 100644
--- a/src/cmd/internal/ld/pe.go
+++ b/src/cmd/internal/ld/pe.go
@@ -1225,12 +1225,13 @@
 	// 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 2b9739f..5719b32 100644
--- a/src/runtime/os1_windows.go
+++ b/src/runtime/os1_windows.go
@@ -282,7 +282,7 @@
 		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")
 	}
 }