Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.82k stars 447 forks source link

Failure in decoding libtorrent DHT alert #4956

Closed xoriole closed 4 years ago

xoriole commented 4 years ago

platform Darwin-18.7.0-x86_64-i386-64bit machine x86_64 python.version 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)

Traceback (most recent call last):
File "TriblerGUI/event_request_manager.py", line 114, in on_read_data
RuntimeError: [Failure instance: Traceback: <class 'RuntimeError'>: expected value (list, dict, int or string) in bencoded string
site-packages/twisted/internet/base.py:1283:run
site-packages/twisted/internet/base.py:1292:mainLoop
site-packages/twisted/internet/base.py:913:runUntilCurrent
site-packages/twisted/internet/task.py:239:__call__
--- <exception caught here> ---
site-packages/twisted/internet/defer.py:151:maybeDeferred
Tribler/Core/Libtorrent/LibtorrentMgr.py:578:_task_process_alerts
]

https://github.com/Tribler/tribler/blob/21fd6cae6866bf5c364479f2d83185e31fc8200c/Tribler/Core/Libtorrent/LibtorrentMgr.py#L577-L583

ichorid commented 4 years ago

Libtorrent versions >1.2.0 produce this error instead of None when encountering incorrect input, namely raw bytes and incorrect syntax. We use updated bindings on our machines, therefore we get this error. However, this could probably be because of alert.pkt_buf changed its type.

ichorid commented 4 years ago

Of course, we could just wrap the thing in a normal try-except block, but we still have to be sure that we can parse correct cases. Otherwise, by applying try-except we would introduce a piece of code that never does anything, and we can't check it.

@devos50 , you developed the BEP33 thing. Could you please fix it for Python 3.7 and ensure that the thing works after the fix (i.e. that BEP33 querying works)?

ichorid commented 4 years ago

@xoriole , we discussed this yesterday, could you please solve it by doing our own wrapper for bdecode that works the same (old) way in all versions of libtorrent?

xoriole commented 4 years ago

Fixed by https://github.com/Tribler/tribler/pull/4975