How do I interpret this error message I get when I try to use http.ListenAndServe()?

0

I have recently started learning Go and have now begun a course where I am building a web service.

I have initilalized my module using go mod init <name>

The simplest reproduction is as follwos

package main

import "net/http"

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello World!"))
    })
    http.ListenAndServe(":8000", nil)
}

When I try to run this using go run .\main.go in the directory I receive the following error

$ go run .\main.go
Exception 0xc0000005 0x0 0x7ffd28cd2fff 0x24ecbd30000
PC=0x24ecbd30000

syscall.Syscall6(0x7ffd289956b0, 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, 0x454a20)       
        c:/go/src/internal/syscall/windows/zsyscall_windows.go:122 +0xcc
net.sysSocket(0x2, 0x1, 0x6, 0x6534e0, 0x0, 0x4a0d65)
        c:/go/src/net/sock_windows.go:20 +0x66
net.(*ipStackCapabilities).probe(0x6852d0)
        c:/go/src/net/ipsock_posix.go:27 +0x55
sync.(*Once).doSlow(0x6852d0, 0xc00008fc38)
        c:/go/src/sync/once.go:66 +0xf7
sync.(*Once).Do(...)
        c:/go/src/sync/once.go:57
net.supportsIPv4map(0xc000072ba0)
        c:/go/src/net/ipsock.go:47 +0x7d
net.favoriteAddrFamily(0x4a0a84, 0x3, 0x4f75c0, 0xc000072ba0, 0x0, 0x0, 0x4a1115, 0x6, 0x4a0d64, 0x5)        
        c:/go/src/net/ipsock_posix.go:120 +0x137
net.internetSocket(0x4f6780, 0xc000014028, 0x4a0a84, 0x3, 0x4f75c0, 0xc000072ba0, 0x0, 0x0, 0x1, 0x0, ...)   
        c:/go/src/net/ipsock_posix.go:140 +0xca
net.(*sysListener).listenTCP(0xc00008fe48, 0x4f6780, 0xc000014028, 0xc000072ba0, 0x4f4080, 0xc000072ba0, 0x3)
        c:/go/src/net/tcpsock_posix.go:168 +0xbe
net.(*ListenConfig).Listen(0xc00008fee0, 0x4f6780, 0xc000014028, 0x4a0a84, 0x3, 0x4a0d64, 0x5, 0xd8, 0x24ecbc40108, 0xc0000b6000, ...)
        c:/go/src/net/dial.go:636 +0x5d9
net.Listen(0x4a0a84, 0x3, 0x4a0d64, 0x5, 0xe0, 0x498a60, 0x652f01, 0xc0000b6000)
        c:/go/src/net/dial.go:706 +0x87
net/http.(*Server).ListenAndServe(0xc0000b6000, 0xc0000b6000, 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/tli.it-minds.dk/dev/go-test/main.go:9 +0x9d
rax     0x7ffd25a00b92
rbx     0x7ffd25a00b90
rcx     0x77
rdi     0xffffffffffbadd11
rsi     0x0
rbp     0x0
rsp     0xf33b9fe750
r8      0x97c
r9      0x97c
r10     0x97c
r11     0x97c
r12     0xc000007a
r13     0x0
r14     0x7ffd25a00b92
r15     0x7ffd28ad0000
rip     0x24ecbd30000
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b
exit status 2

Sometimes I can make it run once or twice after a restart but I will get this error again after that. I often don't even get the stack trace, but just a bunch of values that kind of look like memory addresses.

I have tried running on different ports to make sure it's not in use.

My best guess is that the connection for the program is somehow blocked which caused to server to fail. I am, however, unsure how to unblock this specific progam

Can someone give a pointer as to what is causing this?

UPDATE

This is the other form of error I get

Exception 0xc0000005 0x0 0x7ffd28cd0fff 0x15d42ed0000
PC=0x15d42ed0000

runtime: unknown pc 0x15d42ed0000
stack: frame={sp:0x2587ffe4e0, fp:0x0} stack=[0x0,0x2587fffbc0)
0000002587ffe3e0:  0000002587ffe428  0000002587ffe450 
0000002587ffe3f0:  0000002587ffe418  0000002587ffe410 
0000002587ffe400:  0000002587ffe414  0000015d1dba0000 
0000002587ffe410:  0000000000000000  0000000000000000 
0000002587ffe420:  0000000000000000  0000000000000005 
0000002587ffe430:  0000002587ffe578  00007ffd26aaa2c5 
0000002587ffe440:  0000015d1da63860  00007ffd28af46ce 
0000002587ffe450:  00007ffd28ad00e8  0000015d1da97de0 
0000002587ffe460:  00007ffd26aaa2bf  0000002587ffe4b0 
0000002587ffe470:  004f0044004e0049  0053005c00530057 
0000002587ffe480:  0000015d1da63860  0000000000000000 
0000002587ffe490:  0000015d1da7f040  006c006400050005 
0000002587ffe4a0:  00007ffd26aaa2bf  0000000000000000 
0000002587ffe4b0:  00007ffd00000000  00007ffd28ad00e8 
0000002587ffe4c0:  0000000000000000  0000000000000000 
0000002587ffe4d0:  0000000000000001  00007ffd28af3783 
0000002587ffe4e0: <0000015d00000001  0000000000000000 
0000002587ffe4f0:  0000000000000000  0000002587ffe5e8
0000002587ffe500:  0000000000000000  0000000000000000
0000002587ffe510:  0000000000000000  0000000000000000 
0000002587ffe520:  0000015d1da97de0  00007ffd28c212a0
0000002587ffe530:  0000015d1da63860  00007ffd28c238c0
0000002587ffe540:  000000000000097d  00007ffd2564ccd8
0000002587ffe550:  00007ffd2564a148  00007ffd28c212c8
0000002587ffe560:  00007ffd28c340ef  00007ffd25640000
0000002587ffe570:  00007ffd28c25eb4  00007ffd28b50c40
0000002587ffe580:  0000000000000000  0000000000000000
0000002587ffe590:  0000000000000000  0000000000000000
0000002587ffe5a0:  0000015d1da94800  0000000000000040
0000002587ffe5b0:  0000000000000003  00007ffd28c3b3f0
0000002587ffe5c0:  0000000000000001  0000002587ffe800
0000002587ffe5d0:  0000015d1da7f040  00007ffd28b31568
runtime: unknown pc 0x15d42ed0000
stack: frame={sp:0x2587ffe4e0, fp:0x0} stack=[0x0,0x2587fffbc0)
0000002587ffe3e0:  0000002587ffe428  0000002587ffe450
0000002587ffe3f0:  0000002587ffe418  0000002587ffe410
0000002587ffe400:  0000002587ffe414  0000015d1dba0000
0000002587ffe410:  0000000000000000  0000000000000000
0000002587ffe420:  0000000000000000  0000000000000005
0000002587ffe430:  0000002587ffe578  00007ffd26aaa2c5
0000002587ffe440:  0000015d1da63860  00007ffd28af46ce
0000002587ffe450:  00007ffd28ad00e8  0000015d1da97de0
0000002587ffe460:  00007ffd26aaa2bf  0000002587ffe4b0
0000002587ffe470:  004f0044004e0049  0053005c00530057
0000002587ffe480:  0000015d1da63860  0000000000000000
0000002587ffe490:  0000015d1da7f040  006c006400050005
0000002587ffe4a0:  00007ffd26aaa2bf  0000000000000000
0000002587ffe4b0:  00007ffd00000000  00007ffd28ad00e8
0000002587ffe4c0:  0000000000000000  0000000000000000
0000002587ffe4d0:  0000000000000001  00007ffd28af3783
0000002587ffe4e0: <0000015d00000001  0000000000000000
0000002587ffe4f0:  0000000000000000  0000002587ffe5e8
0000002587ffe500:  0000000000000000  0000000000000000
0000002587ffe510:  0000000000000000  0000000000000000
0000002587ffe520:  0000015d1da97de0  00007ffd28c212a0
0000002587ffe530:  0000015d1da63860  00007ffd28c238c0
0000002587ffe540:  000000000000097d  00007ffd2564ccd8 
0000002587ffe550:  00007ffd2564a148  00007ffd28c212c8 
0000002587ffe560:  00007ffd28c340ef  00007ffd25640000 
0000002587ffe570:  00007ffd28c25eb4  00007ffd28b50c40
0000002587ffe580:  0000000000000000  0000000000000000
0000002587ffe590:  0000000000000000  0000000000000000
0000002587ffe5a0:  0000015d1da94800  0000000000000040
0000002587ffe5b0:  0000000000000003  00007ffd28c3b3f0 
0000002587ffe5c0:  0000000000000001  0000002587ffe800
0000002587ffe5d0:  0000015d1da7f040  00007ffd28b31568
rax     0x7ffd2564d87c
rbx     0x7ffd2564d87a
rcx     0x41
rdi     0xffffffffffbadd11
rsi     0x0
rbp     0x7ffd257ea100
rsp     0x2587ffe4e0
r8      0x0
r9      0x0
r10     0x0
r11     0x97c
r12     0xc000007a
r13     0x0
r14     0x7ffd2564d87c
r15     0x7ffd28ad0000
rip     0x15d42ed0000
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b
go
asked on Stack Overflow Nov 30, 2020 by scarmoose

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0