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
Make stdcopy.StdWriter thread safe. #20706
Make stdcopy.StdWriter thread safe. #20706
Conversation
fd1d239
to
c16a782
Compare
Not fixed :( |
Yes I am. It took a couple of runs but I did get it... also getting a panic from writing to the buffer (slice out of bounds). |
yeah, I saw the panic, but I think it's a completely different issue, caused by using a bounded buffer. |
@cpuguy83 can you try with this other script? Please, make sure you're importing the right package and not a precompiled one without this patch. |
@calavera your script has a bug, it is calling |
Using your branch I still get things like:
Running with |
Thanks @dpiddy it should be fixed now. I wonder what's different in my environment, I don't get any error and I don't have
|
I had to add this back to your script to get the debug output: logrus.StandardLogger().Level = logrus.DebugLevel Can you try that? |
okay, I finally got that corruption error. |
Cool. I think it would be good to eventually fill out the focused test script a bit to include a single net.Conn for stdout & stderr. Much like you needed to lock reads and writes on the buffer I think something similar will need to be done when using a single net.Conn. |
I still think this change fixes the original input header issue, fwiw 😛 |
binary.BigEndian.PutUint32(w.prefix[4:], uint32(len(buf))) | ||
n1, err = w.Writer.Write(w.prefix[:]) | ||
|
||
header := [8]byte{0: w.prefix} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be [stdWriterPrefixLen]byte{...}
instead of [8]byte{...}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe same for 0
-> stdWriterFdIndex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there are a few hardcoded values that we might be able to replace by constants.
Ah, looking over it now I see that stdcopy's |
I'm trying to change that. |
c16a782
to
987891a
Compare
I think that's done it! I was able to run this new test script which uses a tls.Conn for over a minute without weirdness. |
LGTM |
Stop using global variables as prefixes to inject the writer header. That can cause issues when two writers set the length of the buffer in the same header concurrently. Stop Writing to the internal buffer twice for each write. This could mess up with the ordering information is written. Signed-off-by: David Calavera <david.calavera@gmail.com>
987891a
to
443a5c2
Compare
🙌 thanks for checking @dpiddy 🎉 |
LGTM |
retest this |
retest that |
please retest this |
test this please |
Great process, ⭐⭐⭐⭐⭐, would test again. |
Maybe sudo? :) |
Aaaaaaaand it's failing. Halp @SvenDowideit! |
test this please 🙏 |
test this please |
Test is a known failure on win2lin. |
…tdtypes Make stdcopy.StdWriter thread safe.
Stop using global variables as prefixes to inject the writer header.
That can cause issues when two writers set the length of the buffer in
the same header concurrently.
Fixes #19950 (~~maybe?~~totally 🤘)
Signed-off-by: David Calavera david.calavera@gmail.com