aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/stack.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2017-05-18 13:59:00 -0400
committerAustin Clements <austin@google.com>2017-05-23 20:11:07 +0000
commit8a1c5b2e486be7a2df7667582a1b8cd53c8c7745 (patch)
tree7eacd4aad10644d12d8638bc10807de5214cc7c7 /src/runtime/stack.go
parente16944da0e9485db83014e9377860c80cd20f363 (diff)
downloadgo-8a1c5b2e486be7a2df7667582a1b8cd53c8c7745.tar.xz
runtime: fix stackFromSystem returning memory
The stackFromSystem debug mode has two problems: 1) It rounds the stack allocation to _PageSize. If the physical page size is >8K, this can cause unmapping the memory later to either under-unmap or over-unmap. 2) It doesn't return the rounded-up allocation size to its caller, so when we later unmap the memory, we may pass the wrong length. Fix these problems by rounding the size up to the physical page size and putting that rounded-up size in the returned stack bounds. Fixes #17289. Change-Id: I6b854af3b06bb16e3750798397bb5e2a722ec1cb Reviewed-on: https://go-review.googlesource.com/43636 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/stack.go')
-rw-r--r--src/runtime/stack.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/runtime/stack.go b/src/runtime/stack.go
index 562427a6a2..7860cb183e 100644
--- a/src/runtime/stack.go
+++ b/src/runtime/stack.go
@@ -337,7 +337,8 @@ func stackalloc(n uint32) stack {
}
if debug.efence != 0 || stackFromSystem != 0 {
- v := sysAlloc(round(uintptr(n), _PageSize), &memstats.stacks_sys)
+ n = uint32(round(uintptr(n), physPageSize))
+ v := sysAlloc(uintptr(n), &memstats.stacks_sys)
if v == nil {
throw("out of memory (stackalloc)")
}