libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
317 stars 182 forks source link

Panic when using `WithBlacklist` option #426

Closed JackyWYX closed 3 years ago

JackyWYX commented 3 years ago

Description

When running pub-sub with option WithBlacklist, the program panics and exits with the following error:

goroutine 166 [running]:
github.com/libp2p/go-libp2p-pubsub.(*PubSub).processLoop.func1(0xc000381080)
        /home/yx/go/pkg/mod/github.com/libp2p/go-libp2p-pubsub@v0.4.0/pubsub.go:472 +0x85
panic(0x18322a0, 0x1ee0070)
        /usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/libp2p/go-libp2p-pubsub.(*PubSub).processLoop(0xc000381080, 0x1f27790, 0xc001708780)
        /home/yx/go/pkg/mod/github.com/libp2p/go-libp2p-pubsub@v0.4.0/pubsub.go:524 +0xd58
created by github.com/libp2p/go-libp2p-pubsub.NewPubSub
        /home/yx/go/pkg/mod/github.com/libp2p/go-libp2p-pubsub@v0.4.0/pubsub.go:293 +0xb7e

Potential problem

The peer channel is closed but it is not removed from PubSub.peers (Code reference) which will leave a closed peer channel at peers field.