decred / dcrdex

The Decred Decentralized Exchange (DEX), powered by atomic-swaps.
Other
185 stars 92 forks source link

Panic: Close of closed channel #3013

Open ukane-philemon opened 6 days ago

ukane-philemon commented 6 days ago

panic: close of closed channel

goroutine 3300 [running]:
github.com/dcrlabs/ltcwallet/spv.(*delayedCloser).closeNow.func1()
        /{redacted}/go/pkg/mod/github.com/dcrlabs/ltcwallet@v0.0.0-20240823165752-3e026e8da010/spv/query.go:1181 +0x1a
sync.(*Once).doSlow(0xc006464740?, 0x101f5f68d?)
        /usr/local/Cellar/go/1.22.4/libexec/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        /usr/local/Cellar/go/1.22.4/libexec/src/sync/once.go:65
github.com/dcrlabs/ltcwallet/spv.(*delayedCloser).closeNow(0xc008625500?)
        /redacted}/go/pkg/mod/github.com/dcrlabs/ltcwallet@v0.0.0-20240823165752-3e026e8da010/spv/query.go:1180 +0x3c
github.com/dcrlabs/ltcwallet/spv.(*delayedCloser).closeEventually.func1()
        /redacted}/go/pkg/mod/github.com/dcrlabs/ltcwallet@v0.0.0-20240823165752-3e026e8da010/spv/query.go:1174 +0xaa
created by github.com/dcrlabs/ltcwallet/spv.(*delayedCloser).closeEventually in goroutine 2262
        /redacted}/go/pkg/mod/github.com/dcrlabs/ltcwallet@v0.0.0-20240823165752-3e026e8da010/spv/query.go:1167 +0x67
ukane-philemon commented 6 days ago

github.com/dcrlabs/ltcwallet@v0.0.0-20240823165752-3e026e8da010/spv/query.go:1181

// closeNow immediately closes the subject channel. This can safely be called
// multiple times as it will only attempt to close the channel at most once.
func (t *delayedCloser) closeNow() {
    t.once.Do(func() {
        close(t.subject) // This is where the panic came from, It would have been safer to check if the channel is closed before attempting.
    })
}