aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_386.s
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-01-06 12:17:46 -0500
committerAustin Clements <austin@google.com>2016-01-07 19:40:32 +0000
commitfdf9b3c994d832fab925ec1a5acc967289b88c72 (patch)
treea97ce612c6fe50466ab88625b1fbc177f51539fd /src/runtime/sys_windows_386.s
parentb50b24837d34f78dc933027bcc6492df8b963b50 (diff)
downloadgo-fdf9b3c994d832fab925ec1a5acc967289b88c72.tar.gz
go-fdf9b3c994d832fab925ec1a5acc967289b88c72.zip
runtime: increase assumed stack size in externalthreadhandler
On Windows, externalthreadhandler currently sets the assumed stack size for the profiler thread and the ctrlhandler threads to 8KB. The actual stack size is determined by the SizeOfStackReserve field in the binary set by the linker, which is currently at least 64KB (and typically 128KB). It turns out the profiler thread is running within a few words of the 8KB-(stack guard) bound set by externalthreadhandler. If it overflows this bound, morestack crashes unceremoniously with an access violation, which we then fail to handle, causing the whole process to exit without explanation. To avoid this problem and give us some breathing room, increase the assumed stack size in externalthreadhandler to 32KB (there's some unknown amount of stack already in use, so it's not safe to increase this all the way to the reserve size). We also document the relationships between externalthreadhandler and SizeOfStackReserve to make this more obvious in the future. Change-Id: I2f9f9c0892076d78e09827022ff0f2bedd9680a9 Reviewed-on: https://go-review.googlesource.com/18304 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Minux Ma <minux@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 e5fe88afd8..55cdcf407f 100644
--- a/src/runtime/sys_windows_386.s
+++ b/src/runtime/sys_windows_386.s
@@ -206,7 +206,8 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
CALL runtime·memclr(SB) // smashes AX,BX,CX
LEAL g__size(SP), BX
MOVL BX, g_m(SP)
- LEAL -8192(SP), CX
+
+ LEAL -32768(SP), CX // must be less than SizeOfStackReserve set by linker
MOVL CX, (g_stack+stack_lo)(SP)
ADDL $const__StackGuard, CX
MOVL CX, g_stackguard0(SP)