runtime: look up arg stackmap for makeFuncStub/methodValueStub during traceback

makeFuncStub and methodValueStub are used by reflect as
generic function implementations. Each call might have
different arguments. Extract those arguments from the
closure data instead of assuming it is the same each time.

Because the argument map is now being extracted from the
function itself, we don't need the special cases in reflect.Call
anymore, so delete those.

Fixes an occasional crash seen when stack copying does
not update makeFuncStub's arguments correctly.

Will also help make it safe to require stack maps in the
garbage collector.

Derived from CL 142000044 by khr.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143890044
This commit is contained in:
Russ Cox 2014-09-12 07:29:19 -04:00
parent 70f928698b
commit f0d44dbeaf
13 changed files with 161 additions and 49 deletions

View file

@ -481,12 +481,16 @@ adjustframe(Stkframe *frame, void *arg)
}
// adjust inargs and outargs
if(frame->arglen != 0) {
stackmap = runtime·funcdata(f, FUNCDATA_ArgsPointerMaps);
if(stackmap == nil) {
runtime·printf("size %d\n", (int32)frame->arglen);
runtime·throw("no arg info");
if(frame->argmap != nil) {
bv = *frame->argmap;
} else {
stackmap = runtime·funcdata(f, FUNCDATA_ArgsPointerMaps);
if(stackmap == nil) {
runtime·printf("size %d\n", (int32)frame->arglen);
runtime·throw("no arg info");
}
bv = runtime·stackmapdata(stackmap, pcdata);
}
bv = runtime·stackmapdata(stackmap, pcdata);
if(StackDebug >= 3)
runtime·printf(" args\n");
adjustpointers((byte**)frame->argp, &bv, adjinfo, nil);