nspcc-dev / neo-go

Go Node and SDK for the NEO blockchain
MIT License
118 stars 77 forks source link

NPE in WebSocket client subscriptions #3093

Open cthulhu-rider opened 10 months ago

cthulhu-rider commented 10 months ago

caught suddenly while debugging https://github.com/nspcc-dev/neofs-node/pull/2444, don’t have a special context. I subscribe to new blocks and notary requests

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

goroutine 14 [running]:
github.com/nspcc-dev/neo-go/pkg/rpcclient.(*WSClient).notifySubscribers(0xc000224480, {0x16?, {0xa11180?, 0xc000283ea0?}})
    /home/ll/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.101.1/pkg/rpcclient/wsclient.go:599 +0x299
github.com/nspcc-dev/neo-go/pkg/rpcclient.(*WSClient).wsReader(0xc000224480)
    /home/ll/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.101.1/pkg/rpcclient/wsclient.go:513 +0x545
created by github.com/nspcc-dev/neo-go/pkg/rpcclient.NewWS
    /home/ll/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.101.1/pkg/rpcclient/wsclient.go:422 +0x638

may be i violated some strict requirement on my side, but didn't find it after a quick look

AnnaShaleva commented 8 months ago

The issue is caused by the fact that subscriptions map of WS client isn't in sync with receivers map (although it always must be). And currently I can't find where the bug is and also can't reproduce the panic. It's possible that concurrency issue occurs between subsequent event receiving and unsubscription.