-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bytes: Random behavior when reading ssh output with bytes.Buffer #45770
Comments
I'd suggest that you use https://golang.org/wiki/Questions. This could be an issue with your program, such as a data race. Nothing seems to indicate a specific bug in the bytes package. |
Try synchronizing writes: https://play.golang.org/p/GE50s3bxCtY |
There's a race between copying data to the buffer (which may grow) and reading the contents (also between writes from both stdin/stderr)
|
Others confirm my suspicion :) Closing as this is not a bug. |
@seankhliao how did you got those error message ? Thank you, I did not though this was a question. Well I did not except any response from you. May be we can improve the documentation on the crypto/ssh to explicitly warn about possible data race. |
thank you |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I want to excecute a shell command over ssh then write the result into a
bytes.Buffer
and print the content of the Buffer. Here a minimal code reproducing the bug :What did you expect to see?
I want to always see the list of file on my server or a network error.
What did you see instead?
Some time I see nothing. No error and no output from the command. I suspect this to be linked on how the bytes.Buffer work inside since I am reading and writing in it but I have no idea on how make it more minimal.
Obviously when I use my spy I always see the result of my command.
The text was updated successfully, but these errors were encountered: