diff options
| author | 2021-11-24 03:40:23 +0000 | |
|---|---|---|
| committer | 2021-11-24 03:42:35 +0000 | |
| commit | 4ad40d99b08022f532d2eb2e5a4d66b3e3f6c20f (patch) | |
| tree | f0863cde8ac295a2603eee64d4d19056afc3e772 | |
| parent | ae44fd80324212e3b202077ebdae4bec6ac65914 (diff) | |
Add a mutex for soong config var map writes.
Fixes: 207572723
Test: CI
Change-Id: Ide4ca9961b8615186c3ab703c461b6ef53ef656e
| -rw-r--r-- | android/soongconfig/modules.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go index 3a93f478d..09a505722 100644 --- a/android/soongconfig/modules.go +++ b/android/soongconfig/modules.go @@ -20,6 +20,7 @@ import ( "reflect" "sort" "strings" + "sync" "github.com/google/blueprint" "github.com/google/blueprint/parser" @@ -239,10 +240,18 @@ type Bp2BuildSoongConfigDefinitions struct { ValueVars map[string]bool } +var bp2buildSoongConfigVarsLock sync.Mutex + // SoongConfigVariablesForBp2build extracts information from a // SoongConfigDefinition that bp2build needs to generate constraint settings and // values for, in order to migrate soong_config_module_type usages to Bazel. func (defs *Bp2BuildSoongConfigDefinitions) AddVars(mtDef SoongConfigDefinition) { + // In bp2build mode, this method is called concurrently in goroutines from + // loadhooks while parsing soong_config_module_type, so add a mutex to + // prevent concurrent map writes. See b/207572723 + bp2buildSoongConfigVarsLock.Lock() + defer bp2buildSoongConfigVarsLock.Unlock() + if defs.StringVars == nil { defs.StringVars = make(map[string]map[string]bool) } |