]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: clear f, arg to avoid leak in timerproc
authorRuss Cox <rsc@golang.org>
Tue, 18 Feb 2014 01:11:53 +0000 (20:11 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 18 Feb 2014 01:11:53 +0000 (20:11 -0500)
I have seen this cause leaks where not all objects in a sync.Pool
would be reclaimed during the sync package tests.
I found it while debugging the '0 of 100 finalized' failure we are
seeing on arm, but it seems not to be the root cause for that one.

LGTM=dave, dvyukov
R=golang-codereviews, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/64920044

src/pkg/runtime/time.goc

index d52a3b32174840fae9fbb5d779a8649121e16aa3..061d01cf2d1ca2770bed1a2686e551f373eabfe1 100644 (file)
@@ -217,6 +217,14 @@ timerproc(void)
                        if(raceenabled)
                                runtime·raceacquire(t);
                        f(now, arg);
+
+                       // clear f and arg to avoid leak while sleeping for next timer
+                       f = nil;
+                       USED(f);
+                       arg.type = nil;
+                       arg.data = nil;
+                       USED(&arg);
+
                        runtime·lock(&timers);
                }
                if(delta < 0) {