Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

go - Simple web server causing Exception 0xc0000005 windows 10

I'm a student brand new to golang and I'm trying to make a simple web app to learn. For reasons I don't understand if I write any program other than a simple "hello world" I get an Exception 0xc0000005. I've tried rebooting my machine and the error still persists. I think it's some sort of deadlock/POSIX issue?

If it matters, I'm using Windows 10.

Can anyone explain why this keeps happening? Is it something with the code?

Another user had a similar issue here but I don't see how it was resolved.

Thanks in advance.

Simple web app code in main.go:


import (
    "fmt"
    "net/http"
)

func handlerFunc(w http.ResponseWriter, r *http.Request){
    fmt.Fprint(w, "<h1>Welcome to my website</h1>")
}

func main() {
    http.HandleFunc("/", handlerFunc)
    http.ListenAndServe(":8000", nil)
}

Stack trace:

Exception 0xc0000005 0x0 0x7fff6b6d2fff 0x1a6e17b0000
PC=0x1a6e17b0000

syscall.Syscall6(0x7fff6b2656b0, 0x6, 0x2, 0x1, 0x6, 0x0, 0x0, 0x81, 0x0, 0x0, ...)
    C:/Go/src/runtime/syscall_windows.go:201 +0xf2
internal/syscall/windows.WSASocket(0x100000002, 0xc000000006, 0x0, 0x8100000000, 0x10, 0x10, 0x11a4a20)
    C:/Go/src/internal/syscall/windows/zsyscall_windows.go:122 +0xcc
net.sysSocket(0x2, 0x1, 0x6, 0x13a3520, 0x0, 0x11f0d65)
    C:/Go/src/net/sock_windows.go:20 +0x66
net.(*ipStackCapabilities).probe(0x13d5310)
    C:/Go/src/net/ipsock_posix.go:27 +0x55
sync.(*Once).doSlow(0x13d5310, 0xc0000c9c38)
    C:/Go/src/sync/once.go:66 +0xf7
sync.(*Once).Do(...)
    C:/Go/src/sync/once.go:57
net.supportsIPv4map(0xc0000b6ba0)
    C:/Go/src/net/ipsock.go:47 +0x7d
net.favoriteAddrFamily(0x11f0a84, 0x3, 0x12475e0, 0xc0000b6ba0, 0x0, 0x0, 0x11f1115, 0x6, 0x11f0d64, 0x5)
    C:/Go/src/net/ipsock_posix.go:120 +0x137
net.internetSocket(0x12467a0, 0xc0000a2058, 0x11f0a84, 0x3, 0x12475e0, 0xc0000b6ba0, 0x0, 0x0, 0x1, 0x0, ...)
    C:/Go/src/net/ipsock_posix.go:140 +0xca
net.(*sysListener).listenTCP(0xc0000c9e48, 0x12467a0, 0xc0000a2058, 0xc0000b6ba0, 0x12440a0, 0xc0000b6ba0, 0x3)
    C:/Go/src/net/tcpsock_posix.go:168 +0xbe
net.(*ListenConfig).Listen(0xc0000c9ee0, 0x12467a0, 0xc0000a2058, 0x11f0a84, 0x3, 0x11f0d64, 0x5, 0xd8, 0x1a6bacd07b0, 0xc000106000, ...)
    C:/Go/src/net/dial.go:636 +0x5d9
net.Listen(0x11f0a84, 0x3, 0x11f0d64, 0x5, 0xe0, 0x11e8a60, 0x13a2f01, 0xc000106000)
    C:/Go/src/net/dial.go:706 +0x87
net/http.(*Server).ListenAndServe(0xc000106000, 0xc000106000, 0x1)
    C:/Go/src/net/http/server.go:2862 +0x79
net/http.ListenAndServe(...)
    C:/Go/src/net/http/server.go:3120
main.main()
    C:/Users/My laptop/Desktop/go-workspace/main.go:14 +0x9d
rax     0x7fff68450b92
rbx     0x7fff68450b90
rcx     0x77
rdi     0xffffffffffbadd11
rsi     0x0
rbp     0x0
rsp     0x61d4ffee70
r8      0x97c
r9      0x97c
r10     0x97c
r11     0x97c
r12     0xc000007a
r13     0x0
r14     0x7fff68450b92
r15     0x7fff6b4d0000
rip     0x1a6e17b0000
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b


  [1]: https://stackoverflow.com/questions/64050104/golang-keeps-crashing-on-running-main-go-with-exception-exception-0xc0000005

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...