diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-09-27 22:13:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-09-27 22:13:11 +0000 |
commit | 5f18389f4de6f422a50ccd69d63c067e859fc50d (patch) | |
tree | 723725c19f5dbb008b761be51319c63b4010da84 /libgo | |
parent | a84dbde7fc88361e23609be162ba138f96ef18e4 (diff) | |
download | gcc-5f18389f4de6f422a50ccd69d63c067e859fc50d.zip gcc-5f18389f4de6f422a50ccd69d63c067e859fc50d.tar.gz gcc-5f18389f4de6f422a50ccd69d63c067e859fc50d.tar.bz2 |
reflect: Copy stack values onto heap in amd64 MakeFunc.
From-SVN: r202995
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/reflect/makefuncgo_amd64.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libgo/go/reflect/makefuncgo_amd64.go b/libgo/go/reflect/makefuncgo_amd64.go index bdc6556..ecc50a4 100644 --- a/libgo/go/reflect/makefuncgo_amd64.go +++ b/libgo/go/reflect/makefuncgo_amd64.go @@ -431,8 +431,14 @@ argloop: func amd64Memarg(in []Value, ap uintptr, rt *rtype) ([]Value, uintptr) { ap = align(ap, ptrSize) ap = align(ap, uintptr(rt.align)) - p := Value{rt, unsafe.Pointer(ap), flag(rt.Kind()<<flagKindShift) | flagIndir} - in = append(in, p) + + // We have to copy the argument onto the heap in case the + // function hangs onto the reflect.Value we pass it. + p := unsafe_New(rt) + memmove(p, unsafe.Pointer(ap), rt.size) + + v := Value{rt, p, flag(rt.Kind()<<flagKindShift) | flagIndir} + in = append(in, v) ap += rt.size return in, ap } |