anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.58k stars 630 forks source link

Panic when get torrent stats #972

Closed monkeyWie closed 2 months ago

monkeyWie commented 2 months ago

When I call the torrent.Stats() method, there is a certain probability of panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x7ffce875243d]

goroutine 2546 [running]:
github.com/anacrolix/torrent.webrtcNetConn.RemoteAddr({{0x7ffce8da1f40, 0xc0000290c0}, {{0xc0019f1600, 0x1f}, 0x0, {0xaf, 0x30, 0x26, 0x3c, 0x30, ...}, ...}})
    C:/Users/runneradmin/go/pkg/mod/github.com/anacrolix/torrent@v1.56.1/webrtc.go:56 +0x1d
github.com/anacrolix/torrent.(*Torrent).numTotalPeers(0xc000174a88)
    C:/Users/runneradmin/go/pkg/mod/github.com/anacrolix/torrent@v1.56.1/torrent.go:2204 +0x95
github.com/anacrolix/torrent.(*Torrent).statsLocked(0xc000174a88)
    C:/Users/runneradmin/go/pkg/mod/github.com/anacrolix/torrent@v1.56.1/torrent.go:2188 +0xb4
github.com/anacrolix/torrent.(*Torrent).Stats(0xc000174a88)
    C:/Users/runneradmin/go/pkg/mod/github.com/anacrolix/torrent@v1.56.1/torrent.go:2181 +0xba
anacrolix commented 2 months ago

Could you try https://github.com/anacrolix/torrent/tree/issue-972?

monkeyWie commented 2 months ago

I can't reproduce this problem stably, can you release a new version for this? if it happens again, we can reopen it. Thanks!

anacrolix commented 2 months ago

Yes I have release v1.57.0.