Fix data race in a parallel singletons calling VisitAllModules

Force a resort of the module groups before running singletons
so that two singletons running in parallel don't cause a data
race when they trigger a resort in VisitAllModules.

Test: go test -race ./...
Change-Id: Iec041cec08c33c56787aadbde6a1b2b619815142
This commit is contained in:
Colin Cross 2024-01-18 12:14:23 -08:00
parent 6bc984abca
commit e70495ba9a

View file

@ -3520,6 +3520,10 @@ func (c *Context) generateSingletonBuildActions(config interface{},
errs = append(errs, newErrs...)
}
// Force a resort of the module groups before running singletons so that two singletons running in parallel
// don't cause a data race when they trigger a resort in VisitAllModules.
c.sortedModuleGroups()
// First, take care of any singletons that want to run in parallel.
deps, errs = c.generateParallelSingletonBuildActions(config, singletons, liveGlobals)