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.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user