diff options
| author | Russ Cox <rsc@golang.org> | 2012-02-19 00:26:33 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-02-19 00:26:33 -0500 |
| commit | 89b075cc90f260edaa4973bd25258ee653a37a2f (patch) | |
| tree | b674eb55888a5169483f64507f7b47451ff154cc /src/pkg/runtime/proc.c | |
| parent | efacb2a1b48df1a389289c045754ddb30f1a4038 (diff) | |
| download | go-89b075cc90f260edaa4973bd25258ee653a37a2f.tar.xz | |
runtime: fix tiny memory leak
The m->cret word holds the C return value when returning
across a stack split boundary. It was not being cleared after
use, which means that the return value (if a C function)
or else the value of AX/R0 at the time of the last stack unsplit
was being kept alive longer than necessary. Clear it.
I think the effect here should be very small, but worth fixing
anyway.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5677092
Diffstat (limited to 'src/pkg/runtime/proc.c')
| -rw-r--r-- | src/pkg/runtime/proc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index d9047c92c1..eaec093c85 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -1011,6 +1011,7 @@ runtime·oldstack(void) { Stktop *top, old; uint32 argsize; + uintptr cret; byte *sp; G *g1; int32 goid; @@ -1034,7 +1035,9 @@ runtime·oldstack(void) g1->stackbase = old.stackbase; g1->stackguard = old.stackguard; - runtime·gogo(&old.gobuf, m->cret); + cret = m->cret; + m->cret = 0; // drop reference + runtime·gogo(&old.gobuf, cret); } // Called from reflect·call or from runtime·morestack when a new |
