jpillora / cloud-torrent

☁️ Cloud Torrent: a self-hosted remote torrent client
GNU Affero General Public License v3.0
5.83k stars 1.81k forks source link

"panic: not valid until info obtained" after adding torrent from web interface #50

Open vedarthk opened 8 years ago

vedarthk commented 8 years ago

The program panics with following stack trace after adding torrent from web interface:

2016/04/27 09:37:37 Listening at http://0.0.0.0:3000
2016/04/27 09:48:17 http: panic serving 192.168.1.157:53915: not valid until info obtained
goroutine 373 [running]:
net/http.(*conn).serve.func1(0x10d96240)
    /home/pi/go/src/net/http/server.go:1389 +0x9c
panic(0x42c968, 0x10c1d7e8)
    /home/pi/go/src/runtime/panic.go:426 +0x448
github.com/anacrolix/torrent.(*Torrent).Length(0x10e940d0, 0x10fc8280, 0x2d)
    /home/pi/gocode/src/github.com/anacrolix/torrent/t.go:108 +0x74
github.com/jpillora/cloud-torrent/engine.(*Torrent).Update(0x10efc5f0, 0x10e940d0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/torrent.go:41 +0xa0
github.com/jpillora/cloud-torrent/engine.(*Engine).upsertTorrent(0x10a62fc0, 0x10e940d0, 0x11e)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/engine.go:115 +0x158
github.com/jpillora/cloud-torrent/engine.(*Engine).NewTorrent(0x10a62fc0, 0x10fc8240, 0x11e, 0x0, 0x0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/engine.go:78 +0x74
github.com/jpillora/cloud-torrent/server.(*Server).api(0x10aa60f0, 0x10a6a0e0, 0x0, 0x0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/server/server_api.go:70 +0xcc0
github.com/jpillora/cloud-torrent/server.(*Server).handle(0x10aa60f0, 0x74ac5bb8, 0x10e07b00, 0x10a6a0e0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/server/server.go:218 +0x3a8
github.com/jpillora/cloud-torrent/server.(*Server).(github.com/jpillora/cloud-torrent/server.handle)-fm(0x74ac5bb8, 0x10e07b00, 0x10a6a0e0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/server/server.go:161 +0x34
net/http.HandlerFunc.ServeHTTP(0x10bbe440, 0x74ac5bb8, 0x10e07b00, 0x10a6a0e0)
    /home/pi/go/src/net/http/server.go:1618 +0x34
net/http.serverHandler.ServeHTTP(0x10a6d090, 0x74ac5bb8, 0x10e07b00, 0x10a6a0e0)
    /home/pi/go/src/net/http/server.go:2081 +0x190
net/http.(*conn).serve(0x10d96240)
    /home/pi/go/src/net/http/server.go:1472 +0xee4
created by net/http.(*Server).Serve
    /home/pi/go/src/net/http/server.go:2137 +0x3bc
panic: not valid until info obtained

goroutine 51 [running]:
panic(0x42c968, 0x10d2cd40)
    /home/pi/go/src/runtime/panic.go:464 +0x330
github.com/anacrolix/torrent.(*Torrent).Length(0x10e940d0, 0x10fc8280, 0x2d)
    /home/pi/gocode/src/github.com/anacrolix/torrent/t.go:108 +0x74
github.com/jpillora/cloud-torrent/engine.(*Torrent).Update(0x10efc5f0, 0x10e940d0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/torrent.go:41 +0xa0
github.com/jpillora/cloud-torrent/engine.(*Engine).upsertTorrent(0x10a62fc0, 0x10e940d0, 0x1)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/engine.go:115 +0x158
github.com/jpillora/cloud-torrent/engine.(*Engine).GetTorrents(0x10a62fc0, 0x0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/engine/engine.go:102 +0x108
github.com/jpillora/cloud-torrent/server.(*Server).Run.func2(0x10aa60f0)
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/server/server.go:130 +0x58
created by github.com/jpillora/cloud-torrent/server.(*Server).Run
    /home/pi/gocode/src/github.com/jpillora/cloud-torrent/server/server.go:137 +0xab8

Go version:

go version go1.6.1 linux/arm

Is there any more information required ?

jpillora commented 8 years ago

Thanks for the report. Does this occur with all torrents? I presume you've installed from source? If yes and yes, I'm guessing there's been some upstream changes to github.com/anacrolix/torrent which might have broken things...

vedarthk commented 8 years ago

@jpillora yes OK. Yes I have installed from the source. It is failing at: https://github.com/anacrolix/torrent/blob/master/t.go#L106

Looks like following commit has made those changes: https://github.com/anacrolix/torrent/commit/1fab7653294ece3ccd1589cbea9c3b0c77d0f1e6

jpillora commented 8 years ago

Okay cool. When I can, I'll swap from godeps to vendor, which will fix this issue. In the meantime, the pre-built binaries should work fine.

jpillora commented 8 years ago

For those interested in compiling from source and are willing to help out, see https://github.com/jpillora/cloud-torrent/issues/51