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: TestTransportPersistConnLeak test failure/flake on windows 2003 #14375
Comments
Note that you can still use your Go installation, despite this test failure. |
Hm. I haven't seen that one, or at least not in ages. I wonder what they are. |
transport_test.go line 1022: ALL TESTS PASSED |
I can reproduce this:
Am I seeing some unclosed network connections? Brad let me know, if you want me to try something. Alex |
That's too hard to read. I only want to see the new goroutines. See the leak check stuff I added in grpc: https://github.com/grpc/grpc-go/blob/master/test/end2end_test.go // interestingGoroutines returns all goroutines we care about for the purpose
// of leak checking. It excludes testing or runtime ones.
func interestingGoroutines() (gs []string) {
buf := make([]byte, 2<<20)
buf = buf[:runtime.Stack(buf, true)]
for _, g := range strings.Split(string(buf), "\n\n") {
sl := strings.SplitN(g, "\n", 2)
if len(sl) != 2 {
continue
}
stack := strings.TrimSpace(sl[1])
if strings.HasPrefix(stack, "testing.RunTests") {
continue
}
if stack == "" ||
strings.Contains(stack, "testing.Main(") ||
strings.Contains(stack, "runtime.goexit") ||
strings.Contains(stack, "created by runtime.gc") ||
strings.Contains(stack, "interestingGoroutines") ||
strings.Contains(stack, "runtime.MHeap_Scavenger") {
continue
}
gs = append(gs, g)
}
sort.Strings(gs)
return
}
// leakCheck snapshots the currently-running goroutines and returns a
// function to be run at the end of tests to see whether any
// goroutines leaked.
func leakCheck(t testing.TB) func() {
orig := map[string]bool{}
for _, g := range interestingGoroutines() {
orig[g] = true
}
return func() {
// Loop, waiting for goroutines to shut down.
// Wait up to 5 seconds, but finish as quickly as possible.
deadline := time.Now().Add(5 * time.Second)
for {
var leaked []string
for _, g := range interestingGoroutines() {
if !orig[g] {
leaked = append(leaked, g)
}
}
if len(leaked) == 0 {
return
}
if time.Now().Before(deadline) {
time.Sleep(50 * time.Millisecond)
continue
}
for _, g := range leaked {
t.Errorf("Leaked goroutine: %v", g)
}
return
}
}
} |
Sorry for late reply (I lost your reply). I have added leakCheck, but the package already has interestingGoroutines. The TestTransportPersistConnLeak know fails every time - I am sure that is not what you want. Please, let me know what to do. Thank you.
Alex |
ok net 23.938s
--- FAIL: TestTransportPersistConnLeak (0.17s)
transport_test.go:1032: goroutine growth: 24 -> 121 -> 36 (delta: 12)
transport_test.go:1033: too many new goroutines
FAIL
FAIL net/http 19.625s
ok net/http/cgi 2.000s
The text was updated successfully, but these errors were encountered: