From e2efbd35714253270725556bc21bc8a1fd7dd0a1 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 28 Oct 2026 22:32:07 +0800 Subject: [PATCH] gui: a plugin page's host start reads its starter before it goes off on its own pageHost starts the plugin host in a goroutine that can outlive the page's wait, and that goroutine read the package's warmHost when it ran. TestPluginPageStartsItsHost puts warmHost back in its cleanup, so under -race the late read raced the write (seen in a whole race run of internal/gui on mote). pageHost now reads it before the goroutine starts. Run on mote, at this tree (on origin/main 97b6a36c5 plus the maskrec commit before it): - go test -race -count=40 -run 'TestPluginPageStartsItsHost$' ./internal/gui: ok. With pageHost as it was: 1 DATA RACE in 40. - go vet -tags nogui ./internal/gui for linux, windows, darwin: ok Not changed: TestPluginPageReadsWhatItDeclared fails on its second run in one binary (-count=2: "pageSetAllowed"); with -count=1 it passes. Filed as #4076. --- internal/gui/pluginpage.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/gui/pluginpage.go b/internal/gui/pluginpage.go index b4ef4d09d..1952c8298 100644 --- a/internal/gui/pluginpage.go +++ b/internal/gui/pluginpage.go @@ -262,11 +262,12 @@ var warmHost = plugin.Warm // slow one isn't cut off when the page stops waiting. func pageHost(ctx context.Context) { done := make(chan struct{}) + warm := warmHost // read here: the start can outlive the page's wait go func() { defer close(done) c, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() - if err := warmHost(c); err != nil { + if err := warm(c); err != nil { log.Printf("plugin page: starting the plugin host: %v", err) } }()