From: Austin Clements Date: Mon, 7 Mar 2016 22:10:19 +0000 (-0500) Subject: runtime: fix checkmark scanning of finalizers X-Git-Tag: go1.7beta1~1504 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2b19b6e3f109a7a7392d4628ae700833623aa26e;p=gostls13.git runtime: fix checkmark scanning of finalizers 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 Reviewed-by: Rick Hudson TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index a8f460b428..41c53c3c13 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -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