• Austin Clements's avatar
    runtime: ensure finalizers are zero-initialized before reuse · d3836aba
    Austin Clements authored
    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/31454Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
    d3836aba
mgcmark.go 42.6 KB