-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
net/http/httputil: DumpRequestOut can lock up when request cancelled #38352
Comments
Change https://golang.org/cl/227857 mentions this issue: |
@nerd2 There is a data race in the sample program you provided. I believe that using DumpRequestOut while executing the Request is invalid although not documented. once RoundTrip is underway, the request.Body may be altered to handle retries as well as reading the actual body. DumpRequestOut is also manipulating the req.Body which causes the data race mentioned. |
As in #37669, the lock up is internal to DumpRequestOut due to a race between the main thread and the quit and is nothing to do with external body manipulation. I have updated the example to remove the actual request and put it here: If you have a chance to look at the PR in https://github.com/golang/go/pull/38353/files perhaps you can see the issue? |
I can't seem to reproduce the hang. Both your examples always execute and complete. |
Try adding a 1 second sleep on line 2277 of |
With the 1 second delay, I get a race:
|
Or
|
|
Change https://golang.org/cl/232798 mentions this issue: |
We have request debugging in our app which uses The test case added also triggered the above data race, for which I have a two part fix https://golang.org/cl/232798 and https://golang.org/cl/232799 |
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?
If a request is cancelled during net/http httputil.DumpRequestOut, the function can sometimes fail to return
https://play.golang.org/p/-tRCoKCk6XB
What did you expect to see?
The program terminate
What did you see instead?
The program hangs.
Running in dlv, I can two problems. In the locked up case:
In this case, the quitReadCh go function has finished (sent on the reader chan) but the roundtrip has still errored so the dump has locked up
We also have leaked quit goroutines
The text was updated successfully, but these errors were encountered: