This adds diagnostics so we can tell if the finalizer has started, in
addition to whether or not it has finished.
Updates #19381.
Change-Id: Icb7b1b0380c9ad1128b17074828945511a6cca5d
Reviewed-on: https://go-review.googlesource.com/45138
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
. "runtime"
"strings"
"sync"
+ "sync/atomic"
"testing"
"time"
)
go func() {
defer wg.Done()
done := make(chan bool)
+ var started uint32
go func() {
s := new(string)
SetFinalizer(s, func(ss *string) {
+ atomic.StoreUint32(&started, 1)
growStack()
done <- true
})
select {
case <-done:
case <-time.After(20 * time.Second):
+ if atomic.LoadUint32(&started) == 0 {
+ t.Log("finalizer did not start")
+ }
t.Error("finalizer did not run")
return
}