anacrolix / torrent

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

udp tracker panic #845

Closed monkeyWie closed 12 months ago

monkeyWie commented 1 year ago

When I add some tracker URLs, it causes a panic:

panic: read udp4 0.0.0.0:51174: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.

goroutine 1911 [running]:
github.com/anacrolix/torrent/tracker/udp.(*ConnClient).reader(0xc001b3ec80)
        D:/data/go/pkg/mod/github.com/anacrolix/torrent@v1.46.0/tracker/udp/conn-client.go:42 +0x4c5
created by github.com/anacrolix/torrent/tracker/udp.NewConnClient
        D:/data/go/pkg/mod/github.com/anacrolix/torrent@v1.46.0/tracker/udp/conn-client.go:102 +0x3e5

I found this issue https://github.com/anacrolix/torrent/issues/764, and upgraded to the latest version, but it still panics.

reproduce code:

package main

import (
    "github.com/anacrolix/torrent"
)

func main() {
    c, _ := torrent.NewClient(nil)
    defer c.Close()
    t, _ := c.AddMagnet("magnet:?xt=urn:btih:ca21e5baa68fe0edb715f5edf5120aa643218391&dn=[电影天堂www.dytt89.com]铃芽之旅-2022_HD日语中字.mp4")
    t.AddTrackers([][]string{{"udp://tracker.theoks.net:6969/announce"}})
    <-t.GotInfo()
}
anacrolix commented 12 months ago

Thank you for reporting this.