From 15c9d4cb076d7d19152631fb98cb69c163f75008 Mon Sep 17 00:00:00 2001 From: Adam Martin Date: Thu, 13 Aug 2026 21:06:45 -0400 Subject: [PATCH] fix race issue Signed-off-by: Adam Martin --- pkg/content/oci.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/content/oci.go b/pkg/content/oci.go index 4af5ade..6fd8bca 100644 --- a/pkg/content/oci.go +++ b/pkg/content/oci.go @@ -192,6 +192,13 @@ func (o *OCI) AddIndex(desc ocispec.Descriptor) error { } } + // Clone the annotations before storing: the caller keeps its own copy of + // desc (AddArtifact returns the very descriptor it passed here), and + // storeFile/fetchChart annotate that copy afterwards to record the + // original reference. Aliasing the same map into nameMap would let those + // unsynchronized writes race saveIndexLocked's iteration, and would also + // make the follow-up AddIndex compare equal to itself and skip the save. + desc.Annotations = maps.Clone(desc.Annotations) o.nameMap.Store(mapKey, desc) return o.saveIndexCheckpointLocked() }