fix(core): guard bash streaming test callback against concurrent append - #111
Merged
Conversation
…append executeBashStreaming drains stdout and stderr in two separate goroutines, so the ToolOutputCallback it invokes is called concurrently. The production code guards its own stdoutChunks/stderrChunks with a mutex, but the callback added in the streaming tests appended to a shared slice unsynchronised. Under -race this trips a genuine data race. It surfaces only under load — the full suite, or -cpu=1,2,4 — which is why CI on #110 went green and the package passes in isolation. The callback now locks around the append and publishes a snapshot under the same mutex. Test-only change; executeBashStreaming itself was already correct. Introduced by #110.
|
Connected to Huly®: KIT-112 |
|
Warning Review limit reachedNext included review available in 10 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Description
executeBashStreamingdrains stdout and stderr in two separate goroutines, so theToolOutputCallbackit invokes is called concurrently. The production code guards its ownstdoutChunks/stderrChunkswith a mutex, but the test helper added in #110 appended to a shared slice with no synchronisation:Under
-racethis is a genuine data race. It surfaces only under load — the fullgo test -race ./..., or-cpu=1,2,4— which is why CI on #110 went green and the package still passes in isolation. I found it while validating a merge ofmasterinto another branch.This is a test-only fix.
executeBashStreamingitself was already correct.Type of Change
Checklist
go vet,gofmt,golangci-lintall clean)go test -race ./...)Additional Information
Verification
Reproduced on
masterbefore the fix:After the fix, three consecutive
-cpu=1,2,4rounds are clean, plus a fullgo test -race -count=1 ./....The fix
The callback locks around the append, and the final slice is published as a snapshot taken under the same mutex.
executeBashStreaminghas joined both stream goroutines by the time it returns, so no callback can still be in flight — the final lock is for correct publication rather than mutual exclusion, and the comment says so.Note
Introduced by me in #110. CI did not catch it because the race needs concurrent load to manifest, and the
testjob runs the suite in a single pass where scheduling happened to serialise the two goroutines.