arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.15k stars 994 forks source link

libtorrent crashed randomly #5961

Closed NKID00 closed 3 years ago

NKID00 commented 3 years ago

libtorrent version (or branch): libtorrent-rasterbar10/focal 1.2.12-1ppa1~focal1 arm64 (qbittorrent-enhanced-nox/focal 4.3.3.10-1ppa1~focal1 arm64)

platform/architecture: OS: Ubuntu 20.04.2 LTS aarch64 Host: Raspberry Pi 4 Model B Rev 1.1 Kernel: 5.4.0-1028-raspi

compiler and compiler version: Kernel: Linux 4.15.0-132-generic arm64 (aarch64) Toolchain package versions:

Build: https://launchpad.net/~poplite/+archive/ubuntu/qbittorrent-enhanced/+build/20906791 Build log: https://launchpadlibrarian.net/518360229/buildlog_ubuntu-focal-arm64.libtorrent-rasterbar_1.2.12-1ppa1~focal1_BUILDING.txt.gz

please describe what symptom you see, what you would expect to see instead and how to reproduce it. qbittorrent-enhanced-nox crashed a few times radomly. It seemed that the crashes are caused by libtorrent. I have seen two different kinds of errors so far.

$ sudo journalctl | grep qbittorrent-nox

# Skip useless staffs

2月 08 19:16:03 NAS qbittorrent-nox[7627]: double free or corruption (!prev)
2月 08 19:16:03 NAS qbittorrent-nox[7627]: *************************************************************
2月 08 19:16:03 NAS qbittorrent-nox[7627]: Please file a bug report at http://bug.qbittorrent.org and provide the following information:
2月 08 19:16:03 NAS qbittorrent-nox[7627]: qBittorrent version: v4.3.3.10
2月 08 19:16:03 NAS qbittorrent-nox[7627]: Caught signal: SIGABRT
2月 08 19:16:03 NAS qbittorrent-nox[7627]: Stack trace:
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : libtorrent::announce_entry::announce_entry(libtorrent::announce_entry const&)+
0xd8  [0xffff92fdb168]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : BitTorrent::TorrentImpl::trackers() const+0xe8  [0xaaaadc8084f0]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : BitTorrent::TorrentImpl::handleTrackerErrorAlert(libtorrent::tracker_error_alert const*)+0x100  [0xaaaa
dc809248]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : BitTorrent::Session::dispatchTorrentAlert(libtorrent::alert const*)+0x110  [0xaaaadc7cdde0]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : BitTorrent::Session::handleAlert(libtorrent::alert const*)+0xa8  [0xaaaadc7e0bd8]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : BitTorrent::Session::readAlerts()+0x4c  [0xaaaadc7e0eac]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QObject::event(QEvent*)+0x1fc  [0xffff929f45b4]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QCoreApplication::notifyInternal2(QObject*, QEvent*)+0x150  [0xffff929c6e88]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*)+0x168  [0xffff929c
9e00]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : ()+0x2c6a40  [0xffff92a22a40]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libglib-2.0.so.0 : g_main_context_dispatch()+0x274  [0xffff91c18794]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libglib-2.0.so.0 : ()+0x51a04  [0xffff91c18a04]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libglib-2.0.so.0 : g_main_context_iteration()+0x34  [0xffff91c18aa4]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x54  [0xffff92a21ef4]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+0xf8  [0xffff929c5698]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libQt5Core.so.5 : QCoreApplication::exec()+0x9c  [0xffff929cdcac]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : Application::exec(QStringList const&)+0x954  [0xaaaadc7a11ac]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : main()+0x30c  [0xaaaadc79ab2c]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /lib/aarch64-linux-gnu/libc.so.6 : __libc_start_main()+0xe8  [0xffff92358090]
2月 08 19:16:03 NAS qbittorrent-nox[7627]:   /usr/bin/qbittorrent-nox : ()+0x90c4c  [0xaaaadc79dc4c]

# Skip useless staffs

2月 08 19:22:09 NAS qbittorrent-nox[7741]: terminate called after throwing an instance of 'std::length_error'
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   what():  basic_string::_M_create
2月 08 19:22:09 NAS qbittorrent-nox[7741]: *************************************************************
2月 08 19:22:09 NAS qbittorrent-nox[7741]: Please file a bug report at http://bug.qbittorrent.org and provide the following information:
2月 08 19:22:09 NAS qbittorrent-nox[7741]: qBittorrent version: v4.3.3.10
2月 08 19:22:09 NAS qbittorrent-nox[7741]: Caught signal: SIGABRT
2月 08 19:22:09 NAS qbittorrent-nox[7741]: Stack trace:
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libc.so.6 : gsignal()+0xe0  [0xffffa7d68138]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libc.so.6 : abort()+0x110  [0xffffa7d54d68]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : __gnu_cxx::__verbose_terminate_handler()+0x19c  [0xffffa80178ac]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : ()+0x9f1ec  [0xffffa80151ec]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : ()+0x9f250  [0xffffa8015250]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : ()+0x9f544  [0xffffa8015544]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : std::__throw_length_error(char const*)+0x48  [0xffffa8010c1c]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : ()+0x135e6c  [0xffffa80abe6c]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0xc0  [0xffffa80ac260]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : std::vector<libtorrent::announce_endpoint, std::allocator<libtorrent::announce_endpoint> >::operator=(std::vector<libtorrent::announce_endpoint, std::allocator<libtorrent::announce_endpoint> > const&)+0x178  [0xffffa89d84f8]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : libtorrent::announce_entry::operator=(libtorrent::announce_entry const&)+0x30  [0xffffa89d7ff0]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0x252354  [0xffffa8b82354]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0x28adf0  [0xffffa8bbadf0]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0x2ca380  [0xffffa8bfa380]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0x2cfab0  [0xffffa8bffab0]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0xb4944  [0xffffa89e4944]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libtorrent-rasterbar.so.10 : ()+0x1cd944  [0xffffa8afd944]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libstdc++.so.6 : ()+0xccc2c  [0xffffa8042c2c]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libpthread.so.0 : ()+0x84fc  [0xffffa89084fc]
2月 08 19:22:09 NAS qbittorrent-nox[7741]:   /lib/aarch64-linux-gnu/libc.so.6 : ()+0xd467c  [0xffffa7e0567c]

P.S. 2月 08 means Feb. 8th because I am using locale LANG=zh_CN.UTF-8.

arvidn commented 3 years ago

This smells like an ABI incompatibility. Did you build libtorrent yourself, but you use someone else's build for qBittorrent? If so, are you sure they are built with compatible options? Do you have the build log for qbittorrent too?

NKID00 commented 3 years ago

I used the builds of libtorrent and qBittorrent both in this PPA: https://launchpad.net/~poplite/+archive/ubuntu/qbittorrent-enhanced/ Build of qBittorrent: https://launchpad.net/~poplite/+archive/ubuntu/qbittorrent-enhanced/+build/20908342 Build log of qBittorrent: https://launchpadlibrarian.net/518393015/buildlog_ubuntu-focal-arm64.qbittorrent-enhanced_4.3.3.10-1ppa1~focal1_BUILDING.txt.gz

NKID00 commented 3 years ago

I tried to debug using gdb with debug symbols of libtorrent and qBittorrent from this PPA: https://launchpad.net/~poplite/+archive/ubuntu/qbittorrent-enhanced/ and found a different way to crash.

ubuntu@NAS:~$ sudo systemctl start qbittorrent-enhanced-nox.service
ubuntu@NAS:~$ sudo systemctl status qbittorrent-enhanced-nox.service
● qbittorrent-enhanced-nox.service - qBittorrent Enhanced Edition Service
     Loaded: loaded (/lib/systemd/system/qbittorrent-enhanced-nox.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-02-09 16:05:20 CST; 5s ago
       Docs: man:qbittorrent-nox(1)
   Main PID: 21548 (qbittorrent-nox)
      Tasks: 17 (limit: 2102)
     CGroup: /system.slice/qbittorrent-enhanced-nox.service
             └─21548 /usr/bin/qbittorrent-nox

2月 09 16:05:20 NAS systemd[1]: Started qBittorrent Enhanced Edition Service.
ubuntu@NAS:~$ sudo gdb --pid=21548
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 21548
[New LWP 21549]
[New LWP 21550]
[New LWP 21551]
[New LWP 21552]
[New LWP 21553]
[New LWP 21555]
[New LWP 21556]
[New LWP 21557]
[New LWP 21558]
[New LWP 21559]
[New LWP 21566]
[New LWP 21567]
[New LWP 21568]
[New LWP 21569]
[New LWP 21570]
[New LWP 21571]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
futex_wait_cancelable (private=0, expected=0, futex_word=0xaaaaeb9be764) at ../sysdeps/nptl/futex-internal.h:183
183     ../sysdeps/nptl/futex-internal.h: No such file or directory.
(gdb) c
Continuing.
[Thread 0xffff7b7fcdc0 (LWP 21556) exited]
[Thread 0xffff627fadc0 (LWP 21571) exited]
[Thread 0xffff62ffbdc0 (LWP 21570) exited]
[Thread 0xffff637fcdc0 (LWP 21569) exited]
[Thread 0xffff78ea6dc0 (LWP 21567) exited]
[Thread 0xffff796a7dc0 (LWP 21566) exited]
[Thread 0xffff63ffddc0 (LWP 21568) exited]
[New Thread 0xffff63ffddc0 (LWP 21744)]

Thread 1 "qbittorrent-nox" received signal SIGSEGV, Segmentation fault.
0x0000ffff96554808 in __gnu_cxx::__exchange_and_add (__val=-1, __mem=0xffffffffffff000c) at /usr/include/c++/9/bits/stl_construct.h:203
203         _Destroy(_ForwardIterator __first, _ForwardIterator __last,
(gdb) backtrace
#0  0x0000ffff96554808 in __gnu_cxx::__exchange_and_add (__val=-1, __mem=0xffffffffffff000c) at /usr/include/c++/9/bits/stl_construct.h:203
#1  __gnu_cxx::__exchange_and_add_dispatch (__val=-1, __mem=0xffffffffffff000c) at /usr/include/c++/9/ext/atomicity.h:82
#2  std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_weak_release (this=0xffffffffffff0000) at /usr/include/c++/9/bits/shared_ptr_base.h:185
#3  std::__weak_count<(__gnu_cxx::_Lock_policy)2>::~__weak_count (this=0xffff8a0d5000, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:823
#4  std::__weak_ptr<libtorrent::aux::listen_socket_t, (__gnu_cxx::_Lock_policy)2>::~__weak_ptr (this=0xffff8a0d4ff8, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/shared_ptr_base.h:1596
#5  std::weak_ptr<libtorrent::aux::listen_socket_t>::~weak_ptr (this=0xffff8a0d4ff8, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:531
#6  libtorrent::aux::listen_socket_handle::~listen_socket_handle (this=0xffff8a0d4ff8, __in_chrg=<optimized out>) at ../../include/libtorrent/aux_/listen_socket_handle.hpp:44
#7  libtorrent::announce_endpoint::~announce_endpoint (this=0xffff8a0d4fa0, __in_chrg=<optimized out>) at ../../include/libtorrent/announce_entry.hpp:52
#8  std::_Destroy<libtorrent::announce_endpoint> (__pointer=0xffff8a0d4fa0) at /usr/include/c++/9/bits/stl_construct.h:98
#9  std::_Destroy_aux<false>::__destroy<libtorrent::announce_endpoint*> (__last=<optimized out>, __first=0xffff8a0d4fa0) at /usr/include/c++/9/bits/stl_construct.h:108
#10 std::_Destroy<libtorrent::announce_endpoint*> (__last=<optimized out>, __first=<optimized out>) at /usr/include/c++/9/bits/stl_construct.h:137
#11 std::_Destroy<libtorrent::announce_endpoint*, libtorrent::announce_endpoint> (__last=0xffff8a0d5450, __first=<optimized out>)
    at /usr/include/c++/9/bits/stl_construct.h:206
#12 std::vector<libtorrent::announce_endpoint, std::allocator<libtorrent::announce_endpoint> >::~vector (this=0xffff8a347520, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/stl_vector.h:677
#13 libtorrent::announce_entry::~announce_entry (this=0xffff8a3474e0, __in_chrg=<optimized out>) at ../../include/libtorrent/announce_entry.hpp:151
#14 0x0000aaaaaefc553c in std::_Destroy<libtorrent::announce_entry> (__pointer=0xffff8a3474e0) at /usr/include/c++/9/bits/stl_construct.h:97
#15 std::_Destroy_aux<false>::__destroy<libtorrent::announce_entry*> (__last=<optimized out>, __first=0xffff8a3474e0) at /usr/include/c++/9/bits/stl_construct.h:108
#16 std::_Destroy<libtorrent::announce_entry*> (__last=<optimized out>, __first=<optimized out>) at /usr/include/c++/9/bits/stl_construct.h:137
#17 std::_Destroy<libtorrent::announce_entry*, libtorrent::announce_entry> (__last=0xffff8a349520, __first=<optimized out>) at /usr/include/c++/9/bits/stl_construct.h:206
#18 std::vector<libtorrent::announce_entry, std::allocator<libtorrent::announce_entry> >::~vector (this=0xffffe05de510, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/stl_vector.h:677
#19 BitTorrent::TorrentImpl::trackers (this=this@entry=0xaaaaebb466c0) at ../../src/base/bittorrent/torrentimpl.cpp:308
#20 0x0000aaaaaefc6248 in BitTorrent::TorrentImpl::handleTrackerErrorAlert (this=0xaaaaebb466c0, p=<optimized out>) at ../../src/base/bittorrent/torrentimpl.cpp:1486
#21 0x0000aaaaaef8ade0 in BitTorrent::Session::dispatchTorrentAlert (this=0xaaaaeb9b9040, a=0xffff6094e258) at ../../src/base/bittorrent/session.cpp:4664
#22 0x0000aaaaaef9dbd8 in BitTorrent::Session::handleAlert (this=this@entry=0xaaaaeb9b9040, a=0xffff6094e258) at ../../src/base/bittorrent/session.cpp:4592
#23 0x0000aaaaaef9deac in BitTorrent::Session::readAlerts (this=0xaaaaeb9b9040) at ../../src/base/bittorrent/session.cpp:4570
#24 0x0000ffff95f6e5b4 in QObject::event(QEvent*) () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#25 0x0000ffff95f40e88 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#26 0x0000ffff95f43e00 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#27 0x0000ffff95f9ca40 in ?? () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#28 0x0000ffff95192794 in g_main_context_dispatch () from /lib/aarch64-linux-gnu/libglib-2.0.so.0
#29 0x0000ffff95192a04 in ?? () from /lib/aarch64-linux-gnu/libglib-2.0.so.0
#30 0x0000ffff95192aa4 in g_main_context_iteration () from /lib/aarch64-linux-gnu/libglib-2.0.so.0
#31 0x0000ffff95f9bef4 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#32 0x0000ffff95f3f698 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#33 0x0000ffff95f47cac in QCoreApplication::exec() () from /lib/aarch64-linux-gnu/libQt5Core.so.5
#34 0x0000aaaaaef5e1ac in Application::exec (this=0xaaaaeb98bdd0, params=...) at ../../src/app/application.cpp:709
#35 0x0000aaaaaef57b2c in main (argc=<optimized out>, argv=0xffffe05defa8) at /usr/include/c++/9/bits/unique_ptr.h:360
(gdb)

P.S. 2月 09 means Feb. 9th because of the locale LANG=zh_CN.UTF-8.

NKID00 commented 3 years ago

It seemed that all of these three errors are related to libtorrent::announce_entry.

arvidn commented 3 years ago

It seemed that all of these three errors are related to libtorrent::announce_entry.

Which is one of the reasons I think this smells like an ABI issue.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.