rakshasa / rtorrent

rTorrent BitTorrent client
https://github.com/rakshasa/rtorrent/wiki
GNU General Public License v2.0
4.15k stars 414 forks source link

priority_queue_erase(...) could not find item in queue. #1192

Open Antorell opened 1 year ago

Antorell commented 1 year ago

rtorrent randomly crashes when I delete a public torrent from rutorrent. It only seem to happen with public torrent, and right after I delete the torrent+data from rutorrent. I have a bunch of private tracker and I've never had it happen after deleting a torrent from a private tracker.

I just set the network.xmlrpc.size_limit.set to 8M as advised here https://github.com/rakshasa/rtorrent/issues/939#issuecomment-564886523 for another/a similar priority_queue_erase() issue, I'll see if it crashes again.

I built rtorrent/libtorrent from the master tree here on github.

EDIT: it also happens with Private trackers and with network.xmlrpc.size_limit.set set to 8MB+, and this one happened a couple of minutes after rtorrent finished downloading a big torrent.

1668788067 C Caught internal_error: 'priority_queue_erase(...) could not find item in queue.'.
---DUMP---
/usr/local/lib/libtorrent.so.21(_ZN7torrent14internal_error10initializeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x233) [0x7fb736218f83]
/usr/local/bin/rtorrent(_ZN7torrent14internal_errorC1EPKc+0x88) [0x55dd34faa758]
/usr/local/bin/rtorrent(+0x46488) [0x55dd34fab488]
/usr/local/bin/rtorrent(+0xd75b0) [0x55dd3503c5b0]
/usr/local/bin/rtorrent(+0x40c8e) [0x55dd34fa5c8e]
/usr/local/lib/libtorrent.so.21(_ZN7torrent11thread_base10event_loopEPS0_+0x16b) [0x7fb736214cab]
/usr/local/bin/rtorrent(+0x3da1a) [0x55dd34fa2a1a]
/lib/x86_64-linux-gnu/libc.so.6(+0x23510) [0x7fb735a23510]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x89) [0x7fb735a235c9]
/usr/local/bin/rtorrent(+0x3e475) [0x55dd34fa3475]

---END---

Crash after downloading a season pack on a private torrent:

1673537037 C Caught internal_error: 'priority_queue_erase(...) could not find item in queue.'.
---DUMP---
/usr/local/lib/libtorrent.so.21(_ZN7torrent14internal_error10initializeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x7c) [0x7fd27bc78e8c]
/usr/local/bin/rtorrent(_ZN7torrent14internal_errorC1EPKc+0x88) [0x5641636456d8]
/usr/local/bin/rtorrent(+0x46408) [0x564163646408]
/usr/local/bin/rtorrent(+0xd7190) [0x5641636d7190]
/usr/local/bin/rtorrent(+0x40c0e) [0x564163640c0e]
/usr/local/lib/libtorrent.so.21(_ZN7torrent11thread_base10event_loopEPS0_+0x16b) [0x7fd27bc74d5b]
/usr/local/bin/rtorrent(+0x3d9aa) [0x56416363d9aa]
/lib/x86_64-linux-gnu/libc.so.6(+0x23510) [0x7fd27b423510]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x89) [0x7fd27b4235c9]
/usr/local/bin/rtorrent(+0x3e405) [0x56416363e405]

---END---
stickz commented 1 year ago

On line 56 here, you need to inject the following code and recompile to resolve the issue.

if (!m_task.is_valid())
    return;

This problem is caused intentionally with the software. A task becomes invalid before it can be erased. Then the program crashes.

Antorell commented 1 year ago

Thanks, I already patched rtorrent with your PR https://github.com/rakshasa/rtorrent/pull/1134 after it happened the first time back in November. Rtorrent still crashes with it.

I commented the throw torrent::internal_error("priority_queue_erase(...) could not find item in queue."); in rak/priority_queue_default.h, in both libtorrent and rtorrent, and replaced it with a return; I'll see how it goes.

EDIT: returned a segfault instead.