majestrate / XD

meme bittorrent client
https://xd-torrent.github.io/
MIT License
236 stars 25 forks source link

0.0.4 (6380ad7) segfaults when adding torrent file to downloads/ folder #10

Closed mathiasfriman closed 7 years ago

mathiasfriman commented 7 years ago

When adding a torrent file to the downloads/ folder, XD segfaults. This is from when adding i2pupdate-0.9.30.su3 to the folder.

[NFO] 2017-07-30 21:32:35.810096824 +0200 CEST  starting XD-0.0.4-6380ad7
[NFO] 2017-07-30 21:32:35.815348155 +0200 CEST  loaded config torrents.ini
[NFO] 2017-07-30 21:32:35.815416253 +0200 CEST  generated peer id xxxxx
[NFO] 2017-07-30 21:32:35.819436402 +0200 CEST  create new i2p session with 127.0.0.1:7656
[NFO] 2017-07-30 21:32:35.819976207 +0200 CEST  opening i2p session
[NFO] 2017-07-30 21:33:15.840086488 +0200 CEST  i2p session made, we are xxx.b32.i2p
[NFO] 2017-07-30 21:36:12.956807928 +0200 CEST  no bitfield for i2pupdate-0.9.30.su3
[NFO] 2017-07-30 21:36:12.981494118 +0200 CEST  i2pupdate-0.9.30.su3 running
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x61d56b]

goroutine 66 [running]:
     panic(0x7475a0, 0xc4200100f0)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
xd/lib/tracker.(*HttpTracker).Announce(0xc420012800, 0xc42001e150, 0xc4201a0320, 0x0, 0x0)
/home/mathias/source/go/XD/src/xd/lib/tracker/http.go:99 +0x24b
xd/lib/bittorrent/swarm.(*torrentAnnounce).tryAnnounce(0xc4201a4880, 0x7a8845, 0x7, 0x0, 0xc4201122f8)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:38 +0x1db
xd/lib/bittorrent/swarm.(*Torrent).announce(0xc4201080c0, 0x0, 0x0, 0x7a8845, 0x7)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:268 +0xbe
xd/lib/bittorrent/swarm.(*Torrent).StartAnnouncing(0xc4201080c0)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:226 +0x11e
created by xd/lib/bittorrent/swarm.(*Swarm).startTorrent
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/swarm.go:57 +0x235

EDIT: Seems to download/seed when restarting XD though

majestrate commented 7 years ago

does the torrent have and trackers in it by default?

mathiasfriman commented 7 years ago

Yes, tracker2.postman.i2p . I've tried 10 different torrent files with the same result.

I ran with debug enabled, but it didn't give much more relevant info.

[DBG] 2017-07-31 16:04:44.686577432 +0200 CEST  allocate space for i2pupdate-0.9.29.su3
[DBG] 2017-07-31 16:04:44.686604409 +0200 CEST  file is 4468421 bytes
[DBG] 2017-07-31 16:04:44.686628368 +0200 CEST  create file storage/downloads/i2pupdate-0.9.29.su3
[NFO] 2017-07-31 16:04:44.695430885 +0200 CEST  no bitfield for i2pupdate-0.9.29.su3
[DBG] 2017-07-31 16:04:44.695569803 +0200 CEST  sum len=65536 idx=0 ih=1380
[DBG] 2017-07-31 16:04:44.695911547 +0200 CEST  piece 1 of 69
[DBG] 2017-07-31 16:04:44.696039164 +0200 CEST  sum len=65536 idx=20 ih=1380
[DBG] 2017-07-31 16:04:44.696404422 +0200 CEST  piece 2 of 69
[...]
[DBG] 2017-07-31 16:04:44.727693472 +0200 CEST  piece 66 of 69
[DBG] 2017-07-31 16:04:44.727748622 +0200 CEST  sum len=65536 idx=1320 ih=1380
[DBG] 2017-07-31 16:04:44.727952796 +0200 CEST  piece 67 of 69
[DBG] 2017-07-31 16:04:44.728005636 +0200 CEST  sum len=65536 idx=1340 ih=1380
[DBG] 2017-07-31 16:04:44.728237398 +0200 CEST  piece 68 of 69
[DBG] 2017-07-31 16:04:44.728266349 +0200 CEST  sum len=11973 idx=1360 ih=1380
[DBG] 2017-07-31 16:04:44.728315789 +0200 CEST  piece 69 of 69
[NFO] 2017-07-31 16:04:44.728618963 +0200 CEST  i2pupdate-0.9.29.su3 running
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x61d56b]

goroutine 57450 [running]:
panic(0x7475a0, 0xc4200100f0)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
xd/lib/tracker.(*HttpTracker).Announce(0xc4200127c0, 0xc420186000, 0xc420780640, 0x0, 0x0)
/home/mathias/source/go/XD/src/xd/lib/tracker/http.go:99 +0x24b
xd/lib/bittorrent/swarm.(*torrentAnnounce).tryAnnounce(0xc4207ba5c0, 0x7a8845, 0x7, 0x0, 0xc4203d2228)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:38 +0x1db
xd/lib/bittorrent/swarm.(*Torrent).announce(0xc4202ee180, 0x0, 0x0, 0x7a8845, 0x7)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:268 +0xbe
xd/lib/bittorrent/swarm.(*Torrent).StartAnnouncing(0xc4202ee180)
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/torrent.go:226 +0x11e
created by xd/lib/bittorrent/swarm.(*Swarm).startTorrent
/home/mathias/source/go/XD/src/xd/lib/bittorrent/swarm/swarm.go:57 +0x235
majestrate commented 7 years ago

what version of go?

mathiasfriman commented 7 years ago

go version go1.7.1 linux/amd64

majestrate commented 7 years ago

can you try with go 1.8.3 ?

mathiasfriman commented 7 years ago

Yeah, 1.8.3 worked nicely.

majestrate commented 7 years ago

I guess this means someone needs to find all the "bad" versions that don't work. Or I'll require the latest go at all times. Not sure which is better, the easier is to force the latest version of go and not support any others.

mathiasfriman commented 7 years ago

I'll do a little chart and build upon it as I go along. I'll setup my machine with symlinks for go so I can test. So far:

Version Works?
1.8.3 yes
1.8.2 no
1.8.1 no
1.8.0 no
1.7.6 yes
1.7.5 no
1.7.4 no
1.7.3 yes
1.7.1 no
1.7.0 no
1.6.4 yes*
1.6.3

*) No segfault, but maybe other issues.

majestrate commented 7 years ago

thank you for your hard work.

mathiasfriman commented 7 years ago

Haha, thanks but it's not hard, it's just tedious (which you probably know).. :) Just wish I could help in some more constructive way.

majestrate commented 7 years ago

see #11

majestrate commented 7 years ago

Is this the signed release build?

mathiasfriman commented 7 years ago

No, I've compiled it myself. I'll try the signed build and get back.

majestrate commented 7 years ago

I see the problem i think, put in a fix just now.

l-n-s commented 7 years ago
[NFO] 2017-08-10 07:57:26.352576409 +0000 UTC   no bitfield for i2pupdate-0.9.31.su3
[NFO] 2017-08-10 07:57:26.37630772 +0000 UTC    i2pupdate-0.9.31.su3 running
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x55e39f5c8e31]

goroutine 13 [running]:
github.com/majestrate/XD/vendor/xd/lib/tracker.(*HttpTracker).Announce(0xc4200471c0, 0xc420048000, 0xc420014410, 0x0, 0x0)
        /root/go/src/github.com/majestrate/XD/vendor/xd/lib/tracker/http.go:101 +0x431
github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm.(*torrentAnnounce).tryAnnounce(0xc420324140, 0x55e39f688651, 0x7, 0x0, 0xc420056708)
        /root/go/src/github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm/announce.go:32 +0x1f6
github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm.(*Torrent).announce(0xc4200bc180, 0x0, 0x0, 0x55e39f688651, 0x7)
        /root/go/src/github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm/torrent.go:238 +0xca
github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm.(*Torrent).StartAnnouncing(0xc4200bc180)
        /root/go/src/github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm/torrent.go:196 +0x120
created by github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm.(*Swarm).startTorrent
        /root/go/src/github.com/majestrate/XD/vendor/xd/lib/bittorrent/swarm/swarm.go:57 +0x254

Still crashes for me in Docker... confirmed to be working after restart.

go version go1.8.3 linux/amd64

l-n-s commented 7 years ago

Debug output

Update: after restarting it shows and stays like that, file hash doesn't change...

[DBG] 2017-08-10 12:39:31.452298399 +0000 UTC   gave network context to torrents
[NFO] 2017-08-10 12:39:32.424467511 +0000 UTC   i2pupdate-0.9.31.su3 running
[DBG] 2017-08-10 12:39:32.42835159 +0000 UTC     announcing
l-n-s commented 7 years ago

With latest commit, it doesn't crash, but hangs like forever at first start:

[DBG] 2017-08-10 13:54:07.296850037 +0000 UTC   sum len=262144 idx=820 ih=860
[DBG] 2017-08-10 13:54:07.298065685 +0000 UTC   piece 42 of 43
[DBG] 2017-08-10 13:54:07.298758075 +0000 UTC   sum len=64117 idx=840 ih=860
[DBG] 2017-08-10 13:54:07.299507297 +0000 UTC   piece 43 of 43
[NFO] 2017-08-10 13:54:07.300763689 +0000 UTC   Matt Walker-CEH Certified Ethical Hacker Exam Guide-McGraw-Hill (2017).epub running

After restart it prints forever those messages:

[NFO] 2017-08-10 14:17:02.545758921 +0000 UTC   Matt Walker-CEH Certified Ethical Hacker Exam Guide-McGraw-Hill (2017).epub running
[NFO] 2017-08-10 14:17:02.548950852 +0000 UTC   announcing to 
[DBG] 2017-08-10 14:17:02.551075729 +0000 UTC    announcing
[NFO] 2017-08-10 14:17:03.549074217 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:04.549457653 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:03.549074217 +0000 UTC   announcing to                                                                                                     [0/1728]
[NFO] 2017-08-10 14:17:04.549457653 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:05.549071651 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:06.54910089 +0000 UTC    announcing to 
[NFO] 2017-08-10 14:17:07.549075302 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:08.549061054 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:09.549057969 +0000 UTC   announcing to 
...
[NFO] 2017-08-10 14:17:43.549072591 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:44.549024776 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:45.549075176 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:46.549096801 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:47.549064725 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:48.549230436 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:49.549063367 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:50.549090061 +0000 UTC   announcing to 
[NFO] 2017-08-10 14:17:51.549114644 +0000 UTC   announcing to 

Update: hummm it prints something different:

[DBG] 2017-08-10 14:20:50.82452803 +0000 UTC    wrote 68 of 68
[DBG] 2017-08-10 14:20:51.791511934 +0000 UTC   wrote 68 of 68
[DBG] 2017-08-10 14:20:54.895305934 +0000 UTC   didn't complete handshake with peer: EOF
[DBG] 2017-08-10 14:20:54.89565467 +0000 UTC    didn't connect to B0o9bl7dktbT3OPFkC5VY0gEbPKGy1zkz6G3--tK7UxqmJDVVjVPl4EDCbYi-SsqBksQU88aLAaaSntFdLBGmil3Yn5GaIWZTtnDjk6SDNSxKBLplQYDcRAsMReJD2858NNcZ-g~~oewj3hunDl8BrLhm78VmtxeD6WZXHHnCKjBotLmRLKZPeKt4LmlPHWrhW~g8VmrDt5dC2bnhxuRLqvv7HH~mR3Pyc~khaP7JwrQ0X8dS1JmtwOzCtT~c8Hih7COV1T9OC2Gi6lQ6pjIO9jiI96UUFgREYt8Mmj0SPAfNBcfKIE7Z6dFhfjxoGzqSbwS23fqdLQ6DxFzP2jlXQ3vINQQGHC6FxfAKOBk~KtgYaGsYLyAlE~Aad8O4sgSyZCRrFYvshN-VUG0rexhYvXUeX1ynlzT0kkFDPtOM6CI2pt0HKSszNdlqLaYZUyHLjK5z6qibieVxNvWKT4veSxZ4wonfkNiZSZwVHmdqKSGkLv~3y4DAbI0Q77l2NMMBQAEAAcAAA==: EOF
[DBG] 2017-08-10 14:20:57.107692634 +0000 UTC   wrote 68 of 68
[DBG] 2017-08-10 14:20:58.337177372 +0000 UTC   writing 7 bytes
[DBG] 2017-08-10 14:20:58.337750713 +0000 UTC   recv'd header 4 bytes
[DBG] 2017-08-10 14:20:58.340456934 +0000 UTC   got 118 bytes from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B
[DBG] 2017-08-10 14:20:58.34060736 +0000 UTC    Extended from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B
[DBG] 2017-08-10 14:20:58.341310363 +0000 UTC   got extended opts from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B: &{%!s(uint8=0) I2PSnark map[i2p_dht:%!s(uint8=3) i2p_pex:%!s(uint8=2) ut_comment:%!s(uint8=4) ut_metadata:%!s(uint8=1)]}
[DBG] 2017-08-10 14:20:58.341469349 +0000 UTC   recv'd header 4 bytes
[DBG] 2017-08-10 14:20:58.341603849 +0000 UTC   got 7 bytes from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B
[DBG] 2017-08-10 14:20:58.34169219 +0000 UTC    BitField from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B
[DBG] 2017-08-10 14:20:58.341784112 +0000 UTC   got bitfield from %00%00%00%00%00%00%00%00%00%03%03%03%05%C0iIc%3EG%7B
[DBG] 2017-08-10 14:20:58.342033034 +0000 UTC   wrote 11 of 11
[DBG] 2017-08-10 14:20:58.343470156 +0000 UTC   wrote message BitField 7 bytes
[DBG] 2017-08-10 14:20:58.34355572 +0000 UTC    writing 1 bytes
[DBG] 2017-08-10 14:20:58.343681699 +0000 UTC   wrote 5 of 5
[DBG] 2017-08-10 14:20:58.34376267 +0000 UTC    wrote message Interested 1 bytes
majestrate commented 7 years ago

yup fixing now

l-n-s commented 7 years ago

I think I found the way to make it work.

I run XD once, wait to connect to i2p and shut it down.

Then I add torrent file to folder. Then I run XD. It adds torrent before even connecting to i2p, and after that it thinks for a while, and then it starts to announce and download.