From 8b48b472a12d03248c129ef69f2b750805eb55fa Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Tue, 27 May 2025 11:57:04 -0700 Subject: [PATCH] Allocate a buffer and copy compressed chunk rather Otherwise the compression buffer will get stomped on before the results channel is consumed --- go/store/nbs/archive_build.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/go/store/nbs/archive_build.go b/go/store/nbs/archive_build.go index fc40f6a0ba..357f698558 100644 --- a/go/store/nbs/archive_build.go +++ b/go/store/nbs/archive_build.go @@ -385,7 +385,6 @@ func writeDataToArchive( groupCount++ cmpBuff = gozstd.Compress(cmpBuff[:0], cg.dict) - dictId, err := arcW.writeByteSpan(cmpBuff) if err != nil { return 0, 0, 0, err @@ -473,7 +472,11 @@ func compressChunksInParallel( return } cmpBuff = gozstd.CompressDict(cmpBuff[:0], c.Data(), defaultDict) - resultCh <- compressedChunk{h: h, data: cmpBuff} + + // Make a private copy of the compressed data + privateCopy := make([]byte, len(cmpBuff)) + copy(privateCopy, cmpBuff) + resultCh <- compressedChunk{h: h, data: privateCopy} } } }()