go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

invalid memory address or nil pointer dereference in go-libp2p/p2p/transport/websocket

Open JamesHertz opened this issue 3 years ago • 3 comments

After a bit of pain, I was finally able to compile ipfs using the most up-to-date version of go-libp2p. I literally cloned this repository and redirected the ipfs github.com/libp2p to it. I had all this work just to add a new protocol to libp2p and run it on ipfs. But after a few times running ipfs I got this. I don't believe the protocol I added made this bug so I'm reporting it. I hope you fix it as soon as possible :)

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x1805475]

goroutine 1287614 [running]: github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).maDial(0xc001938540, {0x2a442c8, 0xc012642420}, {0x2a58cc0, 0xc00de0c720}) github.com/libp2p/[email protected]/p2p/transport/websocket/websocket.go:186 +0x155 github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).Dial(0xc001938540, {0x2a442c8, 0xc012642420}, {0x2a58cc0, 0xc00de0c720}, {0xc00c4e61e0, 0x26}) github.com/libp2p/[email protected]/p2p/transport/websocket/websocket.go:162 +0xc5 github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).dialAddr(0xc000c31ba0, {0x2a442c8, 0xc012642420}, {0xc00c4e61e0, 0x26}, {0x2a58cc0?, 0xc00de0c720}) github.com/libp2p/[email protected]/p2p/net/swarm/swarm_dial.go:483 +0x1f1 github.com/libp2p/go-libp2p/p2p/net/swarm.(*dialLimiter).executeDial(0xc000c1d590, 0xc012d74740) github.com/libp2p/[email protected]/p2p/net/swarm/limiter.go:219 +0xf0 created by github.com/libp2p/go-libp2p/p2p/net/swarm.(*dialLimiter).addCheckFdLimit github.com/libp2p/[email protected]/p2p/net/swarm/limiter.go:169 +0x4aa

JamesHertz avatar Sep 20 '22 22:09 JamesHertz

Thanks for the bug report. This is my fault. I didn't expect the websocket client to have a nil tls client config. Fix coming right up!

MarcoPolo avatar Sep 20 '22 23:09 MarcoPolo

It happened again. I don't know why but it mostly happens when my ipfs node connects to over 900 peers.

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x180b035]

goroutine 220345 [running]: github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).maDial(0xc000a774d0, {0x2a4c448, 0xc00ba94fc0}, {0x2a60e80, 0xc00c22fdb8}) github.com/libp2p/[email protected]/p2p/transport/websocket/websocket.go:186 +0x155 github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).Dial(0xc000a774d0, {0x2a4c448, 0xc00ba94fc0}, {0x2a60e80, 0xc00c22fdb8}, {0xc007e96c00, 0x26}) github.com/libp2p/[email protected]/p2p/transport/websocket/websocket.go:162 +0xc5 github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).dialAddr(0xc000c64b60, {0x2a4c448, 0xc00ba94fc0}, {0xc007e96c00, 0x26}, {0x2a60e80?, 0xc00c22fdb8}) github.com/libp2p/[email protected]/p2p/net/swarm/swarm_dial.go:483 +0x1f1 github.com/libp2p/go-libp2p/p2p/net/swarm.(*dialLimiter).executeDial(0xc000c5c5f0, 0xc00d305700) github.com/libp2p/[email protected]/p2p/net/swarm/limiter.go:219 +0xf0 created by github.com/libp2p/go-libp2p/p2p/net/swarm.(*dialLimiter).addCheckFdLimit github.com/libp2p/[email protected]/p2p/net/swarm/limiter.go:169 +0x4aa

JamesHertz avatar Sep 21 '22 09:09 JamesHertz

Yeah, this will happen whenever you dial to a node that advertises a websocket address. You could try using the branch with the fix in it marco/fix-nil-pointer and that should fix this for you until we merge that and release

MarcoPolo avatar Sep 21 '22 15:09 MarcoPolo

Sorry, I thought you guys had already merged it. I ran it again and it didn't crash even with more than 900 peers. Thank you for fixing it!!!

JamesHertz avatar Sep 21 '22 16:09 JamesHertz

No problem! I’ll leave this open until we actually merge it :)

MarcoPolo avatar Sep 21 '22 16:09 MarcoPolo

okok

JamesHertz avatar Sep 21 '22 16:09 JamesHertz