-
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
net/http/httptest: Server blocked in Close after 5 seconds, waiting for connections #16555
Comments
Do you run any anti-virus products? If so, which? |
Yes: Microsoft Security Essentials. |
Any change in behavior if you disable it? I ask because 9 times out of 10, bizarre behavior on Windows is caused by antivirus intercepting system calls and not being transparent. I would expect MSE to be better than most, though. We have tests for this too (the example itself is even a test which the builders would test on Windows), so something seems different on your machine than on our testing machines. |
I disabled the real time protection and also included the go firectory and go.exe file on the white list. Didn't helped. Further more i have a lot of network adapters due to vmware/virtualbox, so i disabled all of them, except my real network card. Didn't helped either. Between these investigations, i restartet my pc, also flushed dns. Some more background info, of my pc & work process: starting up, i type in the password to decrypt my HDDs (TrueCrypt). Then i start the git shell (git-bash.exe on windows), there i have to type in the passphrase for my public key (so a ssh-Agent is initialized). After that, i chenge to my go-Coding Directory (in shell), and run the main.go as described. Maybe i sould check some things like VPN Adapters? (Was not connected, but there are windows services in the background) Or general check Windows-Services.. Any suggestions/hints/ideas for further investigations are welcome :) |
Sorry, I'm out of ideas. @alexbrainman, can you reproduce on Windows? |
I tried reproducing this on both current tip and go1.6, but everything works for me as expected. I also use Windows 7. I have no great ideas, but to debug this. Just put fmt.Printf (or println) in the code that is failing. I would start by greping for 'blocked in Close' and see where it takes me. @fraenkel if you can reproduce this reliably, you should be able to see what is broken. Don't hesitate to ask for help. Alex |
I think you meant @fraenky8 |
I sure did. Sorry about that. Alex |
I did further investigations, and i cant figure it out. Played with various network settings, installed latest go version. In a VM the example works (32bit tho). I have no clue, must be a weird composition of some configurations/registry|network settings by all the installed programms (including MS Network Monitor, Wireshark, TeamViewer, Nmap, ...) on my machine i guess. I also tried to debug net/httptest (Intellij Webstorm works great), but i have no idea where to look at. Also i am confused about the connection states: in windows i got 2 connections with state "established" but the go program says, 1 idle connection, for me this are 2 different things. |
I would try to get a stack trace. For example, I made these changes:
You will not need to change I also set
What do you see, if you just add Alex |
I put the panic-call in it and got this output:
Moreover i played aorund last week with some test-cased where the httptest-Server is used (https://github.com/parnurzeal/gorequest/blob/develop/request_test.go) and i realized, if i send a request, lets say GET, because the testServer is waiting for it, on the localhost:port with Hope that ouput helps? |
I compared our stack traces. And you are running:
which is different from what I am running: https://play.golang.org/p/k9beXK-pA- (I don't have _local/playground/packages package. And my main.go line 19 has I suspect your code does something different then mine. I need to see your real code to be able to debug it. Alex |
Sorry!! I encapsulated the httptest-Server in my own function & didn't realized at this moment that this affects the stack trace, my fault m( I put the code from here in https://play.golang.org/p/k9beXK-pA- in main.go with package /issues/issue16555/ and run it using the windows cmd instead if git-bash to avoid unecassary effects on environment etc...
|
Thank you for stack trace. What go version do you use? I assumed you use go1.6, but your some line numbers on your stack trace are wrong. What does Also have you tried running this program using later version of Go (like go1.7rc6 or any recent version)? Could you? Thank you. Alex |
I did a fresh install of go1.6.3 with the provided installer, here is the output of the stacktrace:
Next i installed go1.7rc6 with the provided installer. I ran it without the modification in
Is there a difference to install go from installer or from zip-Package? Maybe the lines changed because i installed go previously by zip...? |
Please try the command "netsh winsock reset" in a admin cmd shell and reboot the computer. Markus |
Actually this worked for me! 👍 But the main reason for this issue is still unclear. I tried to a to create the
|
OK, so it sounds like "netsh winsock reset" cleaned out some bad registry values that something had set? In that case I am not sure there's anything left for Go to do here. Nice bug though. |
What program are you running? Can you point us at it? |
Also how often does it happen? If we fixed the bug could you tell? It's possible this is a dup of #17007 (different failure mode, same cause). |
Unfortunately not, but I can point you to our environment pivotalcf/metrics-ci The program is a simple If you provide a fix we may be able to infer by running our test suite ~50 times or some other high amount and seeing if it pops up. edit: It might be of note that our tests tend to start/stop this server at quite a high rate. edit2: Happy to provide any other info. |
@rsc Apologies, |
@jadekler, if you can reproduce it, send a SIGQUIT to it when it's in that state, and capture all the goroutines and post it here. |
I no longer think this could be caused by #17007. |
@bradfitz Done! It occurred again this morning. See below:
|
@jadekler, that's not a goroutine dump. I want to see the stacks of all active goroutines. A program will dump that on SIGQUIT, but maybe your program overrides SIGQUIT. You might have to arrange to get the stacks some other way. (See https://golang.org/pkg/runtime/#Stack ... and set I can't really help until I see what's happening. |
@bradfitz 👍 Will try that next time it blows up |
Any update here? I guess I'll kick it to Go 1.9, since there's nothing actionable here yet. |
I am currently experiencing the problem for the last 50 tries of my test run.. I wanted to provide you with more context information, but it does not reach my panic and therefore I can not provide you the stack trace. This is how my code looks like: select {
case <-receivedEvent:
fmt.Println("Now I haz event!")
panic("Alarm!")
case <-time.After(250 * time.Millisecond):
t.Error("Timed out waiting for an event")
} The Println is still evaluated but not the panic..
And there it hangs forever.
Let me know if I can help you somehow or how I can provide you better information. BTW I have no antivirus software installed on the Mac (because you were asking others..). I am executing my tests from IntelliJ, but if I execute them on the CLI I just don't get output. PS: I am working on OSS here, so I could provide you an version where it fails for me with a quick guide how to get there. Just don't know if you do such things :) |
@marco-jantke, that code snippet alone is not super helpful. See my question #16555 (comment) above: can you post a goroutine dump? |
Sorry for the interruption, it was basically a programming error in my test case. Fixed it. I was testing a SSE subscription and the client connection to the server was not closed, therefore the server blocked until I would close it. Makes sense. |
Timeout. |
1. What version of Go are you using (
go version
)?go version go1.6 windows/amd64
2. What operating system and processor architecture are you using (
go env
)?Windows 7/x64
git version 2.9.2.windows.1
mingw64 installed
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Eigene Dateien\Coding\go
set GORACE=
set GOROOT=D:\go
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
3. What did you do?
Take the simple server example from https://tip.golang.org/pkg/net/http/httptest/#example_Server and run it with
go run main.go
(https://play.golang.org/p/k9beXK-pA-)4. What did you expect to see?
Hello Client
5. What did you see instead?
Hello, client
2016/07/31 16:30:13 httptest.Server blocked in Close after 5 seconds, waiting for connections:
*net.TCPConn 0xc08202c020 127.0.0.1:4401 in state idle
After 10mins i canceled execution wtih CTRL-C.
The text was updated successfully, but these errors were encountered: