Skip to content

Bootstrap panics if no config has no xBackupBootstrapPeers functions #10030

@gammazero

Description

@gammazero

Checklist

Installation method

built from source

Version

Not running kubo, importing boostrap package from version:
v0.21.0

Config

N/A

Description

I am using the bootstrap package to establish libp2p connections to a set of hosts that I need to exchange gossip pubsub messages with. I am creating the bootstrap config using BootstrapConfigWithPeers. When starting the bootstrapper, with:

bootCfg := BootstrapConfigWithPeers(peerList)
bootCfg.MinPeerThreshold = 2
bootstrapper, err := Bootstrap(peerID, p2pHost, nil, bootCfg)

A panic occurs when the first bootstrap round runs because these functions are not assigned in the configuration:

  • LoadBackupBootstrapPeers
  • SaveBackupBootstrapPeers
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1051bbd20]

goroutine 2259 [running]:
github.com/ipfs/kubo/core/bootstrap.bootstrapRound({0x1065c7bf0?, 0x140008820f0?}, {0x1065d9000, 0x140000f2600}, {0x8, 0x6fc23ac00, 0x2540be400, 0x14000760040, 0x34630b8a000, 0x14, ...})
        /home/ajg/go/pkg/mod/github.com/ipfs/kubo@v0.21.0/core/bootstrap/bootstrap.go:248 +0x190
github.com/ipfs/kubo/core/bootstrap.Bootstrap.func1({0x1065d54f0?, 0x1400074b0e0?})
        /home/ajg/go/pkg/mod/github.com/ipfs/kubo@v0.21.0/core/bootstrap/bootstrap.go:102 +0xcc
github.com/jbenet/goprocess.(*process).Go.func1()
        /home/ajg/go/pkg/mod/github.com/jbenet/goprocess@v0.1.4/impl-mutex.go:134 +0x3c
created by github.com/jbenet/goprocess.(*process).Go
        /home/ajg/go/pkg/mod/github.com/jbenet/goprocess@v0.1.4/impl-mutex.go:133 +0x218

If these functions are expected to be defined, then an error should be returned from Boosstrap. If these functions can be nil, then they should not be called.

I have created a PR to suggest a possible fix: #10029

Related discussion and issue

Issue #9876
Kubo, invalid memory address or nil pointer dereference from IpfsNode.Bootstrap

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA bug in existing code (including security flaws)need/triageNeeds initial labeling and prioritization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions