aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_386.s
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-06-20 16:25:41 -0400
committerAustin Clements <austin@google.com>2018-07-02 15:18:24 +0000
commit52e782a2d6e83065e394d127ea5df20e4aaaa8af (patch)
treea3f7e1792e44421e855f208792b78831e0d5616e /src/runtime/sys_windows_386.s
parentb55fe6a3702922f35b8d440f32fd5a54ee92f5f8 (diff)
downloadgo-52e782a2d6e83065e394d127ea5df20e4aaaa8af.tar.gz
go-52e782a2d6e83065e394d127ea5df20e4aaaa8af.zip
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>
Diffstat (limited to 'src/runtime/sys_windows_386.s')
-rw-r--r--src/runtime/sys_windows_386.s3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/runtime/sys_windows_386.s b/src/runtime/sys_windows_386.s
index 5f0d8b7c2a..56d5cfaa82 100644
--- a/src/runtime/sys_windows_386.s
+++ b/src/runtime/sys_windows_386.s
@@ -315,7 +315,8 @@ TEXT runtimeĀ·tstart(SB),NOSPLIT,$0
// Layout new m scheduler stack on os stack.
MOVL SP, AX
MOVL AX, (g_stack+stack_hi)(DX)
- SUBL $(64*1024), AX // stack size
+ SUBL runtimeĀ·osStackSize(SB), AX // stack size
+ ADDL $(8*1024), AX // slop for calling C
MOVL AX, (g_stack+stack_lo)(DX)
ADDL $const__StackGuard, AX
MOVL AX, g_stackguard0(DX)