-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httptrace: panic on GotConn #34282
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
Comments
Want to do a bisect ? 🙂 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Here is a simpler reproducer that shows the same crash (Edit: simpler still): package main
import (
"context"
"log"
"net/http"
"net/http/httptrace"
"sync"
)
func gotConn(info httptrace.GotConnInfo) {
_ = info.Conn.RemoteAddr // info.Conn == nil here
}
func doGet() {
ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
GotConn: gotConn,
})
req, _ := http.NewRequest(http.MethodGet, "https://google.com", nil)
req = req.WithContext(ctx)
if _, err := http.DefaultClient.Do(req); err != nil {
log.Println(err)
}
}
func main() {
var wg sync.WaitGroup
n := 1000
wg.Add(n)
for i := 0; i < n; i++ {
go func() {
defer wg.Done()
doGet()
}()
}
wg.Wait()
} |
In general, it's better not to edit the original message. Now people reading the thread from the start will get confused by our initial discussion about code that doesn't exist any more. I'll mark our messages as outdated to hide them. |
This is where the call to Lines 1196 to 1199 in 98aa978
Nothing touches Line 936 in 98aa978
Running the go program above in delve, I'm seeing a Line 916 in 98aa978
|
git bisect points to 43b9fcf |
After 43b9fcf, Line 1535 in 98aa978
That When there aren't any idle connections available, x/net/http2 calls Lines 1217 to 1221 in 98aa978
Is the bug here simply that this call is missing the HTTP/2 specific check? Lines 1198 to 1200 in 98aa978
|
@tmthrgd |
Change https://golang.org/cl/195237 mentions this issue: |
CL 195237 fixes the panic, but is missing a test case. @cuonglm If you're looking for a temporary workaround, either: http.DefaultTransport.(*http.Transport).DisableKeepAlives = true or http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = -1 will stop the problematic |
@gopherbot please consider this for backport 1.13 |
Backport issue(s) opened: #34285 (for 1.13). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
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?
Thanks @tmthrgd for simpler and not racy program.
What did you expect to see?
Run successfully.
What did you see instead?
Panic
The program works in go1.12, panic on go1.13 as well as tip.
The text was updated successfully, but these errors were encountered: