aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/stack.go
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2018-11-12 15:49:09 -0800
committerKeith Randall <khr@golang.org>2018-11-13 22:52:09 +0000
commit0098f8aeaceb5feec7462ae64f8ce91a473360c1 (patch)
tree3727380bc1f037536a6cc9933e2a0b3bd183cab3 /src/runtime/stack.go
parentdf2bb9817b2184256886d9d9458753b2273c202d (diff)
downloadgo-0098f8aeaceb5feec7462ae64f8ce91a473360c1.tar.xz
runtime: when using explicit argmap, also use arglen
When we set an explicit argmap, we may want only a prefix of that argmap. Argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall. In this case, arglen specifies how much of the args section is actually live. (It could be either all the args + results, or just the args.) Fixes #28750 Change-Id: Idf060607f15a298ac591016994e58e22f7f92d83 Reviewed-on: https://go-review.googlesource.com/c/149217 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/stack.go')
-rw-r--r--src/runtime/stack.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/stack.go b/src/runtime/stack.go
index 65aa7dbd59..85902a6b68 100644
--- a/src/runtime/stack.go
+++ b/src/runtime/stack.go
@@ -1254,7 +1254,14 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args
// Arguments.
if frame.arglen > 0 {
if frame.argmap != nil {
+ // argmap is set when the function is reflect.makeFuncStub or reflect.methodValueCall.
+ // In this case, arglen specifies how much of the args section is actually live.
+ // (It could be either all the args + results, or just the args.)
args = *frame.argmap
+ n := int32(frame.arglen / sys.PtrSize)
+ if n < args.n {
+ args.n = n // Don't use more of the arguments than arglen.
+ }
} else {
stackmap := (*stackmap)(funcdata(f, _FUNCDATA_ArgsPointerMaps))
if stackmap == nil || stackmap.n <= 0 {