Skip to content

Commit caa9579

Browse files
Alex Couture-Beilalexcb
authored andcommitted
contenthash: data race
Multiple calls to GetCacheContext may occur from multiple threads; however they should only occur when dealing with an ImmutableRef. For this case we still need to perform a lock to prevent data race warnings; however in reality the linkMap will be unused. Signed-off-by: Alex Couture-Beil <[email protected]>
1 parent 86b22f7 commit caa9579

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cache/contenthash/checksum.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ func (cm *cacheManager) GetCacheContext(ctx context.Context, md cache.RefMetadat
110110
cm.lruMu.Unlock()
111111
if ok {
112112
cm.locker.Unlock(md.ID())
113+
v.(*cacheContext).mu.Lock() // locking is required because multiple ImmutableRefs can reach this code; however none of them use the linkMap.
113114
v.(*cacheContext).linkMap = map[string][][]byte{}
115+
v.(*cacheContext).mu.Unlock()
114116
return v.(*cacheContext), nil
115117
}
116118
cc, err := newCacheContext(md)

0 commit comments

Comments
 (0)