• Austin Clements's avatar
    [release-branch.go1.7] runtime: fix getArgInfo for deferred reflection calls · efdb1813
    Austin Clements authored
    Fixes #18333 (backport)
    
    getArgInfo for reflect.makeFuncStub and reflect.methodValueCall is
    necessarily special. These have dynamically determined argument maps
    that are stored in their context (that is, their *funcval). These
    functions are written to store this context at 0(SP) when called, and
    getArgInfo retrieves it from there.
    
    This technique works if getArgInfo is passed an active call frame for
    one of these functions. However, getArgInfo is also used in
    tracebackdefers, where the "call" is not a true call with an active
    stack frame, but a deferred call. In this situation, getArgInfo
    currently crashes because tracebackdefers passes a frame with sp set
    to 0. However, the entire approach used by getArgInfo is flawed in
    this situation because the wrapper has not actually executed, and
    hence hasn't saved this metadata to any stack frame.
    
    In the defer case, we know the *funcval from the _defer itself, so we
    can fix this by teaching getArgInfo to use the *funcval context
    directly when its available, and otherwise get it from the active call
    frame.
    
    While we're here, this commit simplifies getArgInfo a bit by making it
    play more nicely with the type system. Rather than decoding the
    *reflect.methodValue that is the wrapper's context as a *[2]uintptr,
    just write out a copy of the reflect.methodValue type in the runtime.
    
    Fixes #16331. Fixes #17471.
    
    Change-Id: I81db4d985179b4a81c68c490cceeccbfc675456a
    Reviewed-on: https://go-review.googlesource.com/31138
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    Reviewed-on: https://go-review.googlesource.com/35638
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    Reviewed-by: 's avatarAustin Clements <austin@google.com>
    efdb1813
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
context Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang_org/x/net Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
cmp.bash Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
naclmake.bash Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...