nictuku/dht

When I run the example(main.go), I catch this error.

Closed this issue · 1 comments

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0xb9db6]

goroutine 10 [running]:
github.com/nictuku/dht.(_routingTable).kill(0xc20803cb10, 0xc2080980c0)
/Users/yuansc/go/src/github.com/nictuku/dht/routing_table.go:176 +0x136
github.com/nictuku/dht.(_routingTable).cleanup(0xc20803cb10, 0xd18c2e2800, 0xc20802e3c0, 0x0, 0xa)
/Users/yuansc/go/src/github.com/nictuku/dht/routing_table.go:228 +0x8d3
github.com/nictuku/dht.(*DHT).Run(0xc20804e140, 0x0, 0x0)
/Users/yuansc/go/src/github.com/nictuku/dht/dht.go:412 +0x1045
created by main.main
/Users/yuansc/go/src/dht/examples/find_infohash_and_wait/main.go:57 +0x783

goroutine 1 [sleep]:
main.main()
/Users/yuansc/go/src/dht/examples/find_infohash_and_wait/main.go:65 +0x923

goroutine 5 [chan receive]:
github.com/golang/glog.(*loggingT).flushDaemon(0x4a0b00)
/Users/yuansc/go/src/github.com/golang/glog/glog.go:879 +0x78
created by github.com/golang/glog.init·1
/Users/yuansc/go/src/github.com/golang/glog/glog.go:410 +0x2a7

goroutine 17 [syscall, 45 minutes, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 7 [select]:
github.com/nictuku/nettools.(*ClientThrottle).cleanup(0xc20800ab20)
/Users/yuansc/go/src/github.com/nictuku/nettools/ratelimit.go:78 +0x28b
created by github.com/nictuku/nettools.NewThrottler
/Users/yuansc/go/src/github.com/nictuku/nettools/ratelimit.go:19 +0xe8

goroutine 12 [IO wait, 43 minutes]:
net.(_pollDesc).Wait(0xc208010220, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(_pollDesc).WaitRead(0xc208010220, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(_netFD).readFrom(0xc2080101c0, 0xc208094000, 0x1000, 0x1000, 0x0, 0x0, 0x0, 0x566b48, 0xc20802aa10)
/usr/local/go/src/net/fd_unix.go:269 +0x4a1
net.(_UDPConn).ReadFromUDP(0xc20802c050, 0xc208094000, 0x1000, 0x1000, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/udpsock_posix.go:67 +0x124
github.com/nictuku/dht.readFromSocket(0xc20802c050, 0xc208050540, 0xc2080505a0, 0xc208050180)
/Users/yuansc/go/src/github.com/nictuku/dht/krpc.go:231 +0xff
created by github.com/nictuku/dht.(*DHT).Run
/Users/yuansc/go/src/github.com/nictuku/dht/dht.go:307 +0x1eb

goroutine 9 [IO wait, 43 minutes]:
net.(_pollDesc).Wait(0xc2080101b0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(_pollDesc).WaitRead(0xc2080101b0, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(_netFD).accept(0xc208010150, 0x0, 0x566b48, 0xc20802a950)
/usr/local/go/src/net/fd_unix.go:419 +0x40b
net.(_TCPListener).AcceptTCP(0xc20802c048, 0x70cc4, 0x0, 0x0)
/usr/local/go/src/net/tcpsock_posix.go:234 +0x4e
net/http.tcpKeepAliveListener.Accept(0xc20802c048, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:1976 +0x4c
net/http.(_Server).Serve(0xc2080504e0, 0x568200, 0xc20802c048, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:1728 +0x92
net/http.(_Server).ListenAndServe(0xc2080504e0, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:1718 +0x154
net/http.ListenAndServe(0xc20802a910, 0x5, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:1808 +0xba
created by main.main
/Users/yuansc/go/src/dht/examples/find_infohash_and_wait/main.go:55 +0x769

goroutine 11 [chan receive, 43 minutes]:
main.drainresults(0xc20804e140)
/Users/yuansc/go/src/dht/examples/find_infohash_and_wait/main.go:75 +0x32d
created by main.main
/Users/yuansc/go/src/dht/examples/find_infohash_and_wait/main.go:58 +0x79d
exit status 2
yuansc@/go/src/dht/examples/find_infohash_and_wait:$
yuansc@
/go/src/dht/examples/find_infohash_and_wait:$ go run main.go deca7a89a1dbdc4b213de1c0d5351e92582f31fb

I've fixed the panic, but I believe this would only occur when you aren't able to find any DHT nodes. Please check that you have UDP connectivity - which may need NAT mappings to your local host.