You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
I was recently trying to debug some races in an application which uses go-git. My first instinct is to run my tests with race detection enabled.
$ go test -race
Unfortunately when I do that, many races are printed which actually originate in the underlying go-git library code. I was curious about reproducing this, but it looks like they are reproducible by just running the existing tests for some of the ./plumbing/transport/... modules.
It appears there is at least one race in particular that we detect many times related to the goroutine spawned in gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common.(*client).listenErrors()
func (c *client) listenErrors(r io.Reader) chan string {
if r == nil {
return nil
}
errLines := make(chan string, errLinesBuffer)
go func() {
s := bufio.NewScanner(r)
for s.Scan() {
line := string(s.Bytes())
errLines <- line
}
}()
return errLines
}
It appears that by scanning the stderr spawned for the git-upload-pack or git-receive-pack processes in a separate goroutine, we create races when the cmd.Wait() is eventually invoked on the original goroutine.
It appears that things are implemented this way to allow us to timeout while waiting for a "repository not found error". I suspect this timeout behavior is important, but I'm not quite sure of an easy way to address this while avoiding a data race. Maybe we want to put some mutexs around the critical code blocks here which interact with the os/exec command?
Also, maybe the continuous integration for this project should also run tests with race detection enabled? Maybe in addition to the existing builds? Thoughts?
The text was updated successfully, but these errors were encountered:
I was recently trying to debug some races in an application which uses
go-git
. My first instinct is to run my tests with race detection enabled.Unfortunately when I do that, many races are printed which actually originate in the underlying
go-git
library code. I was curious about reproducing this, but it looks like they are reproducible by just running the existing tests for some of the./plumbing/transport/...
modules.It appears there is at least one race in particular that we detect many times related to the goroutine spawned in
gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common.(*client).listenErrors()
It appears that by scanning the stderr spawned for the
git-upload-pack
orgit-receive-pack
processes in a separate goroutine, we create races when thecmd.Wait()
is eventually invoked on the original goroutine.It appears that things are implemented this way to allow us to timeout while waiting for a "repository not found error". I suspect this timeout behavior is important, but I'm not quite sure of an easy way to address this while avoiding a data race. Maybe we want to put some mutexs around the critical code blocks here which interact with the
os/exec
command?Also, maybe the continuous integration for this project should also run tests with race detection enabled? Maybe in addition to the existing builds? Thoughts?
The text was updated successfully, but these errors were encountered: