From fce9d4515defec0473ca3a685408ef5304d23aa9 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 21 May 2025 15:08:08 -0700 Subject: runtime, testing/synctest: verify cleanups/finalizers run outside bubbles Cleanup functions and finalizers must not run in a synctest bubble. If they did, a function run by the GC at an unpredictable time could unblock a bubble that synctest believes is durably blocked. Add a test verifying that cleanups and finalizers are always run by non-bubbled goroutines. (This is already the case because we never add system goroutines to a bubble.) For #67434 Change-Id: I5a48db2b26f9712c3b0dc1f425d99814031a2fc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/675257 Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI Auto-Submit: Damien Neil --- src/testing/synctest/synctest.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/testing') diff --git a/src/testing/synctest/synctest.go b/src/testing/synctest/synctest.go index aeac8c4b43..c7e93b2201 100644 --- a/src/testing/synctest/synctest.go +++ b/src/testing/synctest/synctest.go @@ -83,6 +83,10 @@ // is associated with it. Operating on a bubbled channel, timer, or // ticker from outside the bubble panics. // +// Cleanup functions and finalizers registered with +// [runtime.AddCleanup] and [runtime.SetFinalizer] +// run outside of any bubble. +// // # Example: Context.AfterFunc // // This example demonstrates testing the [context.AfterFunc] function. -- cgit v1.3