Description
In branch v6-transport,
PackSession.Handshake()[starts up a goroutine](https://github.com/go-git/go-git/blob/675edb808690b47e0a9cb99c44a0f2b8245209a6/plumbing/transport/pack.go#L91) to copy data from
stderrto
&c.stderrBufand then [starts something using
cmd.Start()](https://github.com/go-git/go-git/blob/675edb808690b47e0a9cb99c44a0f2b8245209a6/plumbing/transport/pack.go#L97). (What
cmd.Start()` starts seems to depend on the details, but I presume that at least sometimes it needs to be stopped.)
But if PackSession.Handshake()
exits with an error after one or both of these steps is complete, the goroutine, or both the goroutine and the cmd
, are never stopped and seem to be leaked.
Moreover, the same method uses a defer
to copy the stderr buffer into err
. But nothing prevents this defer from running before the copy goroutine has completed writing into the same stderr buffer. This therefore constitutes a data race. (I've observed this race using the race detector.)
/cc @aymanbagabas, who I think worked on this part of the code.