]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix checkmark scanning of finalizers
authorAustin Clements <austin@google.com>
Mon, 7 Mar 2016 22:10:19 +0000 (17:10 -0500)
committerAustin Clements <austin@google.com>
Mon, 7 Mar 2016 22:32:20 +0000 (22:32 +0000)
Currently work.finalizersDone is reset only at the beginning of
gcStart. As a result, it will be set when checkmark runs, so checkmark
will skip scanning finalizers. Hence, if there are any bugs that cause
the regular scan of finalizers to miss pointers, checkmark will also
miss them and fail to detect the missed pointer.

Fix this by resetting finalizersDone in gcResetMarkState. This way it
gets reset before any full mark, which is exactly what we want.

Change-Id: I4ddb5eba5b3b97e52aaf3e08fd9aa692bda32b20
Reviewed-on: https://go-review.googlesource.com/20332
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mgc.go

index a8f460b42873da7c23f839afe5ac9b4be92ef5b3..41c53c3c13f16e8e9a6443ae5965c369630f8dfd 100644 (file)
@@ -949,8 +949,6 @@ func gcStart(mode gcMode, forceTrigger bool) {
        // reclaimed until the next GC cycle.
        clearpools()
 
-       work.finalizersDone = false
-
        if mode == gcBackgroundMode { // Do as much work concurrently as possible
                gcController.startCycle()
                work.heapGoal = gcController.heapGoal
@@ -1738,6 +1736,7 @@ func gcResetMarkState() {
 
        work.bytesMarked = 0
        work.initialHeapLive = memstats.heap_live
+       work.finalizersDone = false
 }
 
 // Hooks for other packages