]> Cypherpunks repositories - gostls13.git/commit
runtime: ensure finalizers are zero-initialized before reuse
authorAustin Clements <austin@google.com>
Fri, 14 Oct 2016 17:39:07 +0000 (13:39 -0400)
committerAustin Clements <austin@google.com>
Fri, 28 Oct 2016 19:13:54 +0000 (19:13 +0000)
commitd3836aba316a6a5ee9410b9abd2f42120af4ffe6
treebdcf971e9a3219937323b2877fc2e17a93957854
parentdb56a63547d7ae9f19afd2497c67f717154f9115
runtime: ensure finalizers are zero-initialized before reuse

We reuse finalizers in finblocks, which are allocated off-heap. This
means they have to be zero-initialized before becoming visible to the
garbage collector. We actually already do this by clearing the
finalizer before returning it to the pool, but we're not careful to
enforce correct memory ordering. Fix this by manipulating the
finalizer count atomically so these writes synchronize properly with
the garbage collector.

Updates #17503.

Change-Id: I7797d31df3c656c9fe654bc6da287f66a9e2037d
Reviewed-on: https://go-review.googlesource.com/31454
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mfinal.go
src/runtime/mgcmark.go