From 5693782e4536dff9b7493e87f8183b0a1c9ffdc0 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 30 Apr 2021 11:39:46 +0200 Subject: [PATCH] fix data race in ValidateCoherency --- validate.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/validate.go b/validate.go index a2c3c86..d4673e4 100644 --- a/validate.go +++ b/validate.go @@ -391,18 +391,19 @@ func (m *Model) ValidateCoherency() error { for path, c := range m.Childs { wg.Add(len(c.Resources.Objects)) for i := range c.Resources.Objects { - go func(i int) { + go func(path string, i int) { defer wg.Done() - r := c.Resources.Objects[i] + res := m.Childs[path].Resources + r := res.Objects[i] if isSolidObject(r) { err := r.Mesh.ValidateCoherency() if err != nil { mu.Lock() - errs = errors.Append(errs, errors.WrapPath(errors.WrapIndex(errors.Wrap(err, r.Mesh), r, i), c.Resources, path)) + errs = errors.Append(errs, errors.WrapPath(errors.WrapIndex(errors.Wrap(err, r.Mesh), r, i), res, path)) mu.Unlock() } } - }(i) + }(path, i) } } wg.Wait()