Skip to content
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: when I ctrl+C terminate the process,and start process again, repeat several times, http.Get function will crash #13079

Closed
aegsea opened this issue Oct 28, 2015 · 4 comments

Comments

Projects
None yet
6 participants
@aegsea
Copy link

commented Oct 28, 2015

http.Get: In version go1.5.1 and win10-x64, when I ctrl+C terminate the process,and start process again, repeate several times,http.Get function will crash.
When I use version go1.4.3, don't have this bug.
===========================codes:============================

package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func getSize(num int) string {
if num > 102410241024 {
return fmt.Sprintf("%.1fGB", float32(num)/1024/1024/1024)
} else if num > 1024*1024 {
return fmt.Sprintf("%.1fMB", float32(num)/1024/1024)
} else if num > 1024 {
return fmt.Sprintf("%.1fKB", float32(num)/1024)
}

return fmt.Sprintf("%dB", num)
}

func downloadUrl(url string) bool {
resp, err := http.Get(url)
if err != nil {
return false
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return false
}

fmt.Println("success download:", url, " ", getSize(len(body)))
return true
}

func main() {
downloadUrl("http://mirrors.163.com/debian/dists/unstable/Release")
downloadUrl("http://mirrors.163.com/debian/dists/unstable/main/source/Sources.gz")
}

===========================errors:============================
D:\code\server-work\golang\project\src\apt-mirror>go build main.go

D:\code\server-work\golang\project\src\apt-mirror>main.exe
success download: http://mirrors.163.com/debian/dists/unstable/Release 248.5KB

D:\code\server-work\golang\project\src\apt-mirror>main.exe
success download: http://mirrors.163.com/debian/dists/unstable/Release 248.5KB

D:\code\server-work\golang\project\src\apt-mirror>main.exe

D:\code\server-work\golang\project\src\apt-mirror>main.exe

D:\code\server-work\golang\project\src\apt-mirror>main.exe
success download: http://mirrors.163.com/debian/dists/unstable/Release 248.5KB

D:\code\server-work\golang\project\src\apt-mirror>main.exe
success download: http://mirrors.163.com/debian/dists/unstable/Release 248.5KB

D:\code\server-work\golang\project\src\apt-mirror>main.exe
Exception 0xe06d7363 0x19930520 0x8f9b0 0x7fff3e21a1c8
PC=0x7fff3e21a1c8

syscall.Syscall9(0x7fff3ecaf0e0, 0x7, 0x294, 0xc08200d1b0, 0x1, 0xc08200d198, 0x0, 0xc08200d168, 0x0, 0x0, ...)
c:/go/src/runtime/syscall_windows.go:150 +0x5c
syscall.WSASend(0x294, 0xc08200d1b0, 0x1, 0xc08200d198, 0x0, 0xc08200d168, 0x0, 0x0, 0x0)
c:/go/src/syscall/zsyscall_windows.go:1529 +0xc4
net.(_netFD).Write.func1(0xc08200d168, 0x0, 0x0)
c:/go/src/net/fd_windows.go:513 +0x8c
net.(_ioSrv).ExecIO(0xc082022040, 0xc08200d168, 0x7055e8, 0x7, 0x783b30, 0x47e320, 0x0, 0x0)
c:/go/src/net/fd_windows.go:160 +0xd5
net.(_netFD).Write(0xc08200d080, 0xc08208c000, 0x7d, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/fd_windows.go:514 +0x181
net.(_conn).Write(0xc082022048, 0xc08208c000, 0x7d, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/net.go:184 +0xeb
bufio.(_Writer).flush(0xc082006640, 0x0, 0x0)
c:/go/src/bufio/bufio.go:562 +0xe7
bufio.(_Writer).Flush(0xc082006640, 0x0, 0x0)
c:/go/src/bufio/bufio.go:551 +0x34
net/http.(_persistConn).writeLoop(0xc082082000)
c:/go/src/net/http/transport.go:1017 +0x2b8
created by net/http.(_Transport).dialConn
c:/go/src/net/http/transport.go:686 +0xca4

goroutine 1 [select]:
net/http.(_persistConn).roundTrip(0xc082082000, 0xc082002b40, 0x0, 0x0, 0x0)
c:/go/src/net/http/transport.go:1164 +0xb14
net/http.(_Transport).RoundTrip(0xc08205a120, 0xc08207e000, 0xc000000002, 0x0, 0x0)
c:/go/src/net/http/transport.go:235 +0x537
net/http.send(0xc08207e000, 0x3c4440, 0xc08205a120, 0xc082006440, 0x0, 0x0)
c:/go/src/net/http/client.go:220 +0x533
net/http.(_Client).send(0x874ea0, 0xc08207e000, 0x34, 0x0, 0x0)
c:/go/src/net/http/client.go:143 +0x161
net/http.(_Client).doFollowingRedirects(0x874ea0, 0xc08207e000, 0x783d40, 0x0, 0x0, 0x0)
c:/go/src/net/http/client.go:380 +0xbc7
net/http.(*Client).Get(0x874ea0, 0x764100, 0x34, 0x4112b9, 0x0, 0x0)
c:/go/src/net/http/client.go:306 +0xb1
net/http.Get(0x764100, 0x34, 0x899a70, 0x0, 0x0)
c:/go/src/net/http/client.go:281 +0x4c
main.downloadUrl(0x764100, 0x34, 0xc08200c100)
D:/code/server-work/golang/project/src/apt-mirror/main.go:22 +0x4f
main.main()
D:/code/server-work/golang/project/src/apt-mirror/main.go:38 +0x33

goroutine 8 [IO wait]:
net.runtime_pollWait(0x3c54c0, 0x72, 0xc082098010)
c:/go/src/runtime/netpoll.go:157 +0x67
net.(_pollDesc).Wait(0xc08200d1f0, 0x72, 0x0, 0x0)
c:/go/src/net/fd_poll_runtime.go:73 +0x41
net.(_ioSrv).ExecIO(0xc082022038, 0xc08200d0e0, 0x7055e0, 0x7, 0x783b28, 0x20, 0x0, 0x0)
c:/go/src/net/fd_windows.go:182 +0x177
net.(_netFD).Read(0xc08200d080, 0xc082011000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/fd_windows.go:463 +0x17e
net.(_conn).Read(0xc082022048, 0xc082011000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/net.go:172 +0xeb
net/http.noteEOFReader.Read(0x3c5580, 0xc082022048, 0xc082082058, 0xc082011000, 0x1000, 0x1000, 0xc082094000, 0x0, 0x0)
c:/go/src/net/http/transport.go:1370 +0x6e
net/http.(_noteEOFReader).Read(0xc082004ec0, 0xc082011000, 0x1000, 0x1000, 0x8, 0x0, 0x0)
:126 +0xd7
bufio.(_Reader).fill(0xc08200e660)
c:/go/src/bufio/bufio.go:97 +0x1f0
bufio.(_Reader).Peek(0xc08200e660, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
c:/go/src/bufio/bufio.go:132 +0xd3
net/http.(_persistConn).readLoop(0xc082082000)
c:/go/src/net/http/transport.go:876 +0xfe
created by net/http.(*Transport).dialConn
c:/go/src/net/http/transport.go:685 +0xc7f
rax 0x0
rbx 0x8f9b0
rcx 0x112f00000000
rdi 0x18006a6b8
rsi 0x26ee6f0
rbp 0x8f980
rsp 0x8f840
r8 0x0
r9 0x8f460
r10 0x7fff3e1ff437
r11 0x2a24b0
r12 0x1
r13 0x1
r14 0xc08200d1b0
r15 0x294
rip 0x7fff3e21a1c8
rflags 0x206
cs 0x33
fs 0x53
gs 0x2b

@bradfitz

This comment has been minimized.

Copy link
Member

commented Oct 28, 2015

@alexbrainman, does this mean anything to you?

@alexbrainman

This comment has been minimized.

Copy link
Member

commented Oct 28, 2015

It looks like Windows API code is throwing an Exception for some reason - http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx

I am not sure if there is anything for us to do. Currently we crash process if exception is thrown in code outside of Go.

Alex

@rakyll rakyll changed the title http.Get: when I ctrl+C terminate the process,and start process again, repeate several times,http.Get function will crash. net/http: when I ctrl+C terminate the process,and start process again, repeat several times, http.Get function will crash Oct 28, 2015

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Nov 5, 2015

@zhangyoufu

This comment has been minimized.

Copy link

commented Apr 9, 2018

Cannot reproduce on go1.10, Windows 10.0.16299.309 amd64

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 9, 2018

ETIMEOUT

@bradfitz bradfitz closed this Apr 9, 2018

@golang golang locked and limited conversation to collaborators Apr 9, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.