]> Cypherpunks repositories - gostls13.git/commit
runtime: fix finalizer flakiness
authorRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 14:46:40 +0000 (09:46 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 14:46:40 +0000 (09:46 -0500)
commit241f63debddc1ceb9a890241a91534a8080117a3
tree94ed00871cf87db1a52ca1f6fd514dd34a3f7d71
parentd1c6c6004be6d2c3ad030c5c1ef5ae1c84c7d293
runtime: fix finalizer flakiness

The flakiness appears to be just in tests, not in the actual code.
Specifically, the many tests call runtime.GC once and expect that
the finalizers will be running in the background when GC returns.
Now that the sweep phase is concurrent with execution, however,
the finalizers will not be run until sweep finishes, which might
be quite a bit later. To force sweep to finish, implement runtime.GC
by calling the actual collection twice. The second will complete the
sweep from the first.

This was reliably broken after a few runs before the CL and now
passes tens of runs:

while GOMAXPROCS=2 ./runtime.test -test.run=Finalizer -test.short \
        -test.timeout=300s -test.cpu=$(perl -e 'print ("1,2,4," x 100) . "1"')
do true; done

Fixes #7328.

LGTM=dvyukov
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/71080043
src/pkg/runtime/malloc.goc