koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

Segfault when unboxing block fails in connectForkHead() #111

Closed theoreticalbts closed 3 years ago

theoreticalbts commented 3 years ago

I got a segfault with the following log:

$ build/koinos_p2p --seed asdfasdf -a amqp://guest:guest@159.65.252.160:5672/ -p /ip4/45.56.104.152/tcp/8888/p2p/QmXbaznRypMJRE9Zbea8tbCHF2CMyDWmQ1pH8mYsqHvkFR
2021-06-10 15:16:36.309730 (p2p.1gAEU) [koinos-p2p/main.go:122] <info>: Attempting to connect to block_store...
2021-06-10 15:16:36.309840 (p2p.1gAEU) [koinos-mq-golang@v0.0.0-20210422163354-8a0ef0ba028d/client.go:84] <info>: Connecting client to AMQP server amqp://guest:guest@159.65.252.160:5672/
2021-06-10 15:16:36.309937 (p2p.1gAEU) [koinos-mq-golang@v0.0.0-20210422163354-8a0ef0ba028d/connection.go:85] <info>: Dialing AMQP server amqp://guest:guest@159.65.252.160:5672/
2021-06-10 15:16:36.870940 (p2p.1gAEU) [koinos-mq-golang@v0.0.0-20210422163354-8a0ef0ba028d/client.go:103] <info>: Client connected
2021-06-10 15:16:39.452756 (p2p.1gAEU) [koinos-p2p/main.go:128] <info>: Connected
2021-06-10 15:16:39.452796 (p2p.1gAEU) [koinos-p2p/main.go:134] <info>: Attempting to connect to chain...
2021-06-10 15:16:39.511510 (p2p.1gAEU) [koinos-p2p/main.go:140] <info>: Connected
2021-06-10 15:16:39.521689 (p2p.1gAEU) [node/peer_reconnect.go:100] <info>: Attempting to connect to peer QmXbaznRypMJRE9Zbea8tbCHF2CMyDWmQ1pH8mYsqHvkFR
2021-06-10 15:16:39.521688 (p2p.1gAEU) [koinos-mq-golang@v0.0.0-20210422163354-8a0ef0ba028d/request_handler.go:107] <info>: Connecting request handler to AMQP server amqp://guest:guest@159.65.252.160:5672/
2021-06-10 15:16:39.521812 (p2p.1gAEU) [koinos-mq-golang@v0.0.0-20210422163354-8a0ef0ba028d/connection.go:85] <info>: Dialing AMQP server amqp://guest:guest@159.65.252.160:5672/
2021-06-10 15:16:39.522065 (p2p.1gAEU) [koinos-p2p/main.go:155] <info>: Starting node at address: /ip4/127.0.0.1/tcp/8888/p2p/QmZ68yByc7vELj1dqrvTy91xwAPEbjdAXQQa8uiQ44qd36
2021-06-10 15:16:39.574657 (p2p.1gAEU) [protocol/download_provider.go:368] <info>: Connecting disconnected fork head {%!s(koinos.UInt64=18) G�و�sJO
                                                                                                                                                   3��lV����"�y:��V}
2021-06-10 15:16:39.640495 (p2p.1gAEU) [protocol/download_provider.go:348] <warn>: Could not unbox connecting block: opaque type not unboxed
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa02dc6]

goroutine 93 [running]:
github.com/koinos/koinos-p2p/internal/protocol.(*BdmiProvider).connectForkHead(0xc0002442a0, 0xec12f0, 0xc0000c6000, 0x12, 0xc00003e3e0, 0x20, 0x20, 0x0, 0x0, 0x13bf4c8, ...)
        /home/u/b/p/koinos-p2p/internal/protocol/download_provider.go:353 +0x246
github.com/koinos/koinos-p2p/internal/protocol.(*BdmiProvider).HandleForkHeads(0xc0002442a0, 0xec12f0, 0xc0000c6000, 0xc00007e6c0)
        /home/u/b/p/koinos-p2p/internal/protocol/download_provider.go:369 +0x676
github.com/koinos/koinos-p2p/internal/protocol.(*BdmiProvider).initialize(0xc0002442a0, 0xec12f0, 0xc0000c6000)
        /home/u/b/p/koinos-p2p/internal/protocol/download_provider.go:234 +0x1a5
github.com/koinos/koinos-p2p/internal/protocol.(*BdmiProvider).Start.func1(0xc0002442a0, 0xec12f0, 0xc0000c6000)
        /home/u/b/p/koinos-p2p/internal/protocol/download_provider.go:467 +0x45
created by github.com/koinos/koinos-p2p/internal/protocol.(*BdmiProvider).Start
        /home/u/b/p/koinos-p2p/internal/protocol/download_provider.go:466 +0x53

The problem is that we should continue after log.Warnf("Could not unbox connecting block: %v", err).