]> Cypherpunks repositories - gostls13.git/commit
runtime: initialize g0 stack bounds on Windows to full stack
authorAustin Clements <austin@google.com>
Wed, 20 Jun 2018 20:25:41 +0000 (16:25 -0400)
committerAustin Clements <austin@google.com>
Mon, 2 Jul 2018 15:18:24 +0000 (15:18 +0000)
commit52e782a2d6e83065e394d127ea5df20e4aaaa8af
treea3f7e1792e44421e855f208792b78831e0d5616e
parentb55fe6a3702922f35b8d440f32fd5a54ee92f5f8
runtime: initialize g0 stack bounds on Windows to full stack

Currently, we allocate 1MB or 2MB thread stacks on Windows, but in
non-cgo binaries still set the g0 stack bounds assuming only 64k is
available. While this is fine in pure Go binaries, a non-cgo Go binary
on Windows can use the syscall package to call arbitrary DLLs, which
may call back into Go. If a DLL function uses more than 64k of stack
and then calls back into Go, the Go runtime will believe that it's out
of stack space and crash.

Fix this by plumbing the correct stack size into the g0 stacks of
non-cgo binaries. Cgo binaries already use the correct size because
their g0 stack sizes are set by a different code path.

Fixes #20975.

Change-Id: Id6fb559cfe1e1ea0dfac56d4654865c20dccf68d
Reviewed-on: https://go-review.googlesource.com/120195
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/pe.go
src/runtime/cgo/gcc_windows_386.c
src/runtime/cgo/gcc_windows_amd64.c
src/runtime/os_windows.go
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s