Wrap singleton ninjaString Eval calls

This avoids a concurrent map read and write error in parallel
singletons.

Bug: 290795374
Test: manual, treehugger
Change-Id: I7f89909a98c4f530da92a3d2cc01ca8eaeddbfa0
This commit is contained in:
LaMont Jones 2023-07-11 19:58:01 +00:00
parent 5d3bfd147b
commit 7c2ebdef75
2 changed files with 7 additions and 1 deletions

View file

@ -229,6 +229,12 @@ func (l *liveTracker) innerAddNinjaStringDeps(str *ninjaString) error {
return nil
}
func (l *liveTracker) Eval(n *ninjaString) (string, error) {
l.Lock()
defer l.Unlock()
return n.Eval(l.variables)
}
func (l *liveTracker) RemoveVariableIfLive(v Variable) bool {
l.Lock()
defer l.Unlock()

View file

@ -289,7 +289,7 @@ func (s *singletonContext) Eval(pctx PackageContext, str string) (string, error)
return "", err
}
return ninjaStr.Eval(s.globals.variables)
return s.globals.Eval(ninjaStr)
}
func (s *singletonContext) RequireNinjaVersion(major, minor, micro int) {