core/bazel: fix race#135
Open
sywhang wants to merge 1 commit into
Open
Conversation
There's a race in `streamOutput` and `streamAndParseTargets` where the stderr buffer was being read / written concurrently. When the context gets cancelled and bails, it's trying to read the buffer while it's still being written to by the other goroutine. The streaming goroutine should block until the other goroutine exits, so that it doesn't attempt to read the byte buffer concurrently. Fixes #134.
yushan8
approved these changes
Jun 30, 2026
sbalabanov
requested changes
Jun 30, 2026
|
|
||
| select { | ||
| case <-ctx.Done(): | ||
| <-done |
Contributor
There was a problem hiding this comment.
this blocks on copying goroutine, in which case it does not make any sense to have a goroutine at all but rather block on a main thread.
what we need to have instead is a cancellable Copy, or at least a cancellable io.Reader.
This wrapper is better than nothing on pure blocking reads: https://github.com/uber/tango/pull/108/changes#diff-279a703791b2ff1b50139ea545c8aca00928b154a414330229e4891ec895aaf2
Author
There was a problem hiding this comment.
the main thread is already blocked before we call errgroup.Wait() because we're calling cmd.Wait().
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.
There's a race in
streamOutputandstreamAndParseTargetswhere the stderr buffer was being read / written concurrently. When the context gets cancelled and bails, it's trying to read the buffer while it's still being written to by the other goroutine.The streaming goroutine should block until the other goroutine exits, so that it doesn't attempt to read the byte buffer concurrently.
Fixes #134.