RTECO-1263 - Fixed Content Reader race panic#3502
Merged
Merged
Conversation
ff1257b to
7b5a0d8
Compare
udaykb2
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
masterbranch.go vet ./....go fmt ./....Summary
Fixes
panic: send on closed channelinContentReadertriggered intermittently by concurrent use ofNextRecordandReset(or by callers that invokeResetinternally, e.g.Length,SortContentReader).Resolves RTECO-1263.
Background
ContentReader.NextRecordspawns a producer goroutine once (viasync.Once) that streams JSON array elements from one or more files intocr.dataChannel. The receiver inNextRecordand the producer inreadSingleFileboth readcr.dataChannelfrom the struct field on each access.Reset()replaces bothcr.dataChannelandcr.oncewithout any synchronization. This created three independent race conditions that together produce the panic:Reset()had swapped the channelfield. The producer's next send would land on the new channel, which could already have been closed by the next cycle's
defer close.NextRecordcould fireonce.Doagainst the oldonce, then readcr.dataChannelafterReset()had swapped both fields, causing the receiverand producer to operate on different channels (deadlock).
defer close(cr.dataChannel)evaluates the channel argument at defer-registration time, butcr.dataChannel <- itemre-reads the field on everysend. The defer and the send could refer to two different channels.
The race is timing-dependent; it surfaces in CI under load (e.g.
TestPushFatManifestImageWithNestedPathin the docker test suite) but is hard to reproduce locally without-raceand concurrent stress.
Stack trace from the failing CI run:
panic: send on closed channel
goroutine 2699 [running]:
github.com/jfrog/jfrog-client-go/utils/io/content.(*ContentReader).readSingleFile
.../utils/io/content/contentreader.go:216 +0x492
github.com/jfrog/jfrog-client-go/utils/io/content.(*ContentReader).run(...)
.../utils/io/content/contentreader.go:178
github.com/jfrog/jfrog-client-go/utils/io/content.(*ContentReader).NextRecord.func1.1()
.../utils/io/content/contentreader.go:78 +0x7a