]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: fix garbage collection bug in Call.
authorRuss Cox <rsc@golang.org>
Mon, 18 Jan 2010 23:59:50 +0000 (15:59 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 18 Jan 2010 23:59:50 +0000 (15:59 -0800)
Fixes #476.

R=r
CC=golang-dev
https://golang.org/cl/190041

src/pkg/reflect/value.go

index 3c77b879c01ea79df0a823c111a9a7056246dcd4..30314ddba58c44a9ea9a4dc494855df0b7ccc7c2 100644 (file)
@@ -829,15 +829,19 @@ func (fv *FuncValue) Call(in []Value) []Value {
        if size < 8 {
                size = 8
        }
-       args := make([]byte, size)
-       ptr := uintptr(unsafe.Pointer(&args[0]))
+
+       // round to pointer size
+       size = (size + ptrSize - 1) &^ (ptrSize - 1)
 
        // Copy into args.
        //
        // TODO(rsc): revisit when reference counting happens.
-       // This one may be fine.  The values are holding up the
-       // references for us, so maybe this can be treated
-       // like any stack-to-stack copy.
+       // The values are holding up the in references for us,
+       // but something must be done for the out references.
+       // For now make everything look like a pointer by pretending
+       // to allocate a []*int.
+       args := make([]*int, size/ptrSize)
+       ptr := uintptr(unsafe.Pointer(&args[0]))
        off := uintptr(0)
        delta := 0
        if v := fv.first; v != nil {