diff options
| author | Austin Clements <austin@google.com> | 2018-07-06 09:55:33 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-07-07 14:44:09 +0000 |
| commit | d6b56bb301470c62634d1747cc155489c4e0f18a (patch) | |
| tree | c0b61a4568c22caef7065ea560745b51fdd5496e /src/runtime | |
| parent | 7001ac53946bb05c88a0e7d7c3c64dfb1cca1fca (diff) | |
| download | go-d6b56bb301470c62634d1747cc155489c4e0f18a.tar.xz | |
runtime: account for guard zone in Windows stack size
Windows includes an 8K guard in system-allocated thread stacks, which
we currently don't account for when setting the g0 stack bounds. As a
result, if we do overflow the g0 stack bounds, we'll get a
STATUS_GUARD_PAGE_VIOLATION exception, which we're not expecting.
Fix the g0 stack bounds to include a total of 16K of slop to account
for this 8K guard.
Updates #21382.
Change-Id: Ia89b741b1413328e4681a237f5a7ee645531fe16
Reviewed-on: https://go-review.googlesource.com/122516
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/os_windows.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index bf5baea13e..6f73a5ba24 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -698,10 +698,12 @@ func minit() { print("runtime: VirtualQuery failed; errno=", getlasterror(), "\n") throw("VirtualQuery for stack base failed") } - // Add 8K of slop for calling C functions that don't have - // stack checks. We shouldn't be anywhere near this bound - // anyway. - base := mbi.allocationBase + 8*1024 + // The system leaves an 8K PAGE_GUARD region at the bottom of + // the stack (in theory VirtualQuery isn't supposed to include + // that, but it does). Add an additional 8K of slop for + // calling C functions that don't have stack checks. We + // shouldn't be anywhere near this bound anyway. + base := mbi.allocationBase + 16<<10 // Sanity check the stack bounds. g0 := getg() if base > g0.stack.hi || g0.stack.hi-base > 64<<20 { |
