From 0098f8aeaceb5feec7462ae64f8ce91a473360c1 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 12 Nov 2018 15:49:09 -0800 Subject: 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 TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements --- src/runtime/stack.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/runtime/stack.go') 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 { -- cgit v1.3-5-g9baa