aborts due to bad lexical cast

Bug #349906 reported by Igor Vlasenko
2
Affects Status Importance Assigned to Milestone
libtorrent-rasterbar
Fix Released
Unknown
qBittorrent
Invalid
High
Christophe Dumez

Bug Description

qbittorrent 1.3.2 + rasterbar 0.14.2
qbittorrent sometimes crashes
when seeding a lot of torrents (about 100)
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what(): bad lexical cast: source type value could not be interpreted as target

Program received signal SIGABRT, Aborted.

I built a debug versions of qbittorrent 1.3.2 + rasterbar 0.14.2,
and tried ddd and kdbg. Unfortunately, it seems to be not good for multithread debuging,
so I didn't find the exact location :(

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

What version of boost are you using?

I have absolutely no idea of where this bug could be in qbittorrent's code. I will try to ask libtorrent author in case he has an idea (could likely be in his code).

a gdb backtrace would also be more than welcome :) Did you compile it yourself or did you use packages?
Would you be able to recompile libtorrent with debug enabled?

Changed in qbittorrent:
assignee: nobody → hydr0g3n
importance: Undecided → High
milestone: none → 1.3.3
Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Forwarded to libtorrent-rasterbar author. Libtorrent-rasterbar *does* use lexical_cast from boost library. qBittorrent does not.

Changed in qbittorrent:
status: New → Triaged
Changed in libtorrent-rasterbar:
status: Unknown → New
Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Libtorrent's author would really need a backtrace. Could you please do the following:
$ gdb qbittorrent
> catch throw (if it fails, try: "break _cxa_throw")
Make breakpoint pending on future shared library load? (y or [n]) y
> run
... Wait until it hits the breackpoint
> bt full

Then paste the backtrace here. Thanks in advance.

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

1) boost = 0.36.0
2) arch = x86_64
libtorrent-rasterbar 0.14.2 built with Og, not stripped:
file /usr/lib64/libtorrent-rasterbar.so.2.0.0
/usr/lib64/libtorrent-rasterbar.so.2.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), not stripped

thanks for help, I run qbittorrent again under gdb as requested,
now I am waiting for bug to happen.
When I have no or a few uploads, nothing bad happens :(

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

how I started gdb.
-------------------------------------
GNU gdb 6.6-alt3 (ALT Linux)
...
This GDB was configured as "x86_64-alt-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) catch throw
Function "__cxa_throw" not defined.
(gdb) break _cxa_throw
Function "_cxa_throw" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (_cxa_throw) pending.
(gdb) run
Starting program: /home/archive/gitrepo/qbittorrent.git/qbittorrent/qbittorrent
[Thread debugging using libthread_db enabled]
[New Thread 139788082653008 (LWP 30680)]
[New Thread 1113073984 (LWP 30683)]
[New Thread 1084275008 (LWP 30684)]
[New Thread 1092667712 (LWP 30689)]
[New Thread 1101060416 (LWP 30690)]

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

nothing interesting was in backtrace.
Maybe I should try to built
libtorrent-rasterbar as a static library and link it to qbittorrent stratically.
....
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30717)]
[Thread 1121466688 (LWP 30717) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30718)]
[Thread 1121466688 (LWP 30718) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30727)]
[Thread 1121466688 (LWP 30727) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30730)]
[Thread 1121466688 (LWP 30730) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30738)]
[Thread 1121466688 (LWP 30738) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30739)]
[Thread 1121466688 (LWP 30739) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30740)]
[Thread 1121466688 (LWP 30740) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30741)]
[Thread 1121466688 (LWP 30741) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30742)]
[Thread 1121466688 (LWP 30742) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30743)]
[Thread 1121466688 (LWP 30743) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30744)]
[Thread 1121466688 (LWP 30744) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30749)]
[Thread 1121466688 (LWP 30749) exited]
QLayout: Attempting to add QLayout "" to properties "properties", which already has a layout
[New Thread 1121466688 (LWP 30750)]
[Thread 1121466688 (LWP 30750) exited]
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what(): bad lexical cast: source type value could not be interpreted as target

Program received signal SIGABRT, Aborted.
[Switching to Thread 1084275008 (LWP 30684)]
0x00007f22f035f665 in raise () from /lib64/libc.so.6
(gdb)

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Backtrace with "bt full".

Did you try? What you posted is not a backtrace.

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

sorry, I forget. shame on me :(
from another run:
....
Program received signal SIGABRT, Aborted.
[Switching to Thread 1096878400 (LWP 3701)]
0x00007f831d9f5665 in raise () from /lib64/libc.so.6
(gdb) bt full
#0 0x00007f831d9f5665 in raise () from /lib64/libc.so.6
No symbol table info available.
#1 0x00007f831d9f6ae0 in abort () from /lib64/libc.so.6
No symbol table info available.
#2 0x00007f831e24ebb4 in __gnu_cxx::__verbose_terminate_handler ()
   from /usr/lib64/libstdc++.so.6
No symbol table info available.
#3 0x00007f831e24cd76 in std::basic_streambuf<char, std::char_traits<char> >::setbuf () from /usr/lib64/libstdc++.so.6
No symbol table info available.
#4 0x00007f831e24cda3 in std::terminate () from /usr/lib64/libstdc++.so.6
No symbol table info available.
#5 0x00007f831d3a396f in thread_proxy ()
   from /usr/lib64/libboost_thread-mt.so.1.36.0
No symbol table info available.
#6 0x00007f831f643fb7 in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#7 0x00007f831da8278d in clone () from /lib64/libc.so.6
No symbol table info available.

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

and before is
(gdb) break _cxa_throw
Function "_cxa_throw" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (_cxa_throw) pending.
(gdb) run
Starting program: /home/archive/gitrepo/qbittorrent.git/qbittorrent/qbittorrent
[Thread debugging using libthread_db enabled]
[New Thread 140201161394000 (LWP 3697)]
[New Thread 1113901376 (LWP 3700)]
[New Thread 1096878400 (LWP 3701)]
[New Thread 1105271104 (LWP 3706)]
Warning: Local domain socket was not closed cleanly, deleting file...
[New Thread 1122294080 (LWP 3723)]
terminate called after throwing an instance of 'boost::exception_detail::clone_i
mpl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what(): bad lexical cast: source type value could not be interpreted as targe
t

Program received signal SIGABRT, Aborted.
[Switching to Thread 1096878400 (LWP 3701)]
0x00007f831d9f5665 in raise () from /lib64/libc.so.6

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

the program is still running, other threads still alive.

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

after crash main window becomes empty, but exists, there is also a tray icon, and some network activity continues.

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

what do you mean it is still running? You can't type anything in gdb?

backtrace for all threads is like this:
thread apply all bt

see https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/286205 more more information.

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

it is a multithread program,
...
[New Thread 140201161394000 (LWP 3697)]
[New Thread 1113901376 (LWP 3700)]
[New Thread 1096878400 (LWP 3701)]
[New Thread 1105271104 (LWP 3706)]
...
so when one of them crashed, other threads was still alive
and the program as a whole was still running.
I did
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb)
The program is not being run.
(gdb) quit

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

thanks for help, now I will try
thread apply all bt

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :
Download full text (10.6 KiB)

[New Thread 1088903488 (LWP 24269)]
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what(): bad lexical cast: source type value could not be interpreted as target

Program received signal SIGABRT, Aborted.
[Switching to Thread 1108678976 (LWP 24263)]
0x00007fa4a1673665 in raise () from /lib64/libc.so.6
(gdb) thread apply all bt
[empty lines where I cut the message (---Type <return> to continue, or q <return> to quit---)]
Thread 5 (Thread 1088903488 (LWP 24269)):
#0 0x00007fa4a16f86a6 in poll () from /lib64/libc.so.6
#1 0x00007fa4975c14c4 in std::basic_streambuf<char, std::char_traits<char> >::setbuf () from /lib64/libresolv.so.2
#2 0x00007fa4975c05c6 in __libc_res_nquery () from /lib64/libresolv.so.2
#3 0x00007fa4975c0837 in std::basic_streambuf<char, std::char_traits<char> >::setbuf () from /lib64/libresolv.so.2
#4 0x00007fa4975c0b60 in __libc_res_nsearch () from /lib64/libresolv.so.2
#5 0x00007fa4977cf44f in _nss_dns_gethostbyname3_r ()
   from /lib64/libnss_dns.so.2
#6 0x00007fa4977cf6c4 in _nss_dns_gethostbyname2_r ()
   from /lib64/libnss_dns.so.2
#7 0x00007fa4a17142e5 in gethostbyname2_r () from /lib64/libc.so.6
#8 0x00007fa4a16ed2fc in std::basic_streambuf<char, std::char_traits<char> >::setbuf () from /lib64/libc.so.6
#9 0x00007fa4a16eddcf in getaddrinfo () from /lib64/libc.so.6
#10 0x00007fa4a3b6b1d7 in boost::asio::detail::socket_ops::getaddrinfo ()
   from /usr/lib64/libtorrent-rasterbar.so.2
#11 0x00007fa4a3bfe242 in boost::asio::detail::resolver_service<boost::asio::ip::tcp>::resolve_query_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, libtorrent::http_connection, boost::system::error_code const&, boost::asio::ip::basic_resolver_

e<boost::shared_ptr<libtorrent::http_connection> >, boost::arg<1>, boost::arg<2> > > >::operator() () from /usr/lib64/libtorrent-rasterbar.so.2
#12 0x00007fa4a3bfe3c1 in boost::asio::asio_handler_invoke<boost::asio::detail::resolver_service<boost::asio::ip::tcp>::resolve_query_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, libtorrent::http_connection, boost::system::error_code const&, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >, boost::_bi::list3<boost::_bi::value<boost::shared_ptr<libtorrent::http_connection> >, boost::arg<1>, boost::arg<2> > > > > ()
   from /usr/lib64/libtorrent-rasterbar.so.2
#13 0x00007fa4a3bfe3e9 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::resolver_service<boost::asio::ip::tcp>::resolve_query_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, libtorrent::http_connection, boost::system::error_code const&, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >, boost::_bi::list3<boost::_bi::value<boost::shared_ptr<libtorrent::http_connection> >, boost::arg<1>, boost::arg<2> > > >, boost::asio::detail::resolver_service<boost::asio::ip::tcp>::resolve_query_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, libtorrent::http_connection, boost::system::error_code const&, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >, boost::_bi::list3<boost::_bi::value<boost::shared_ptr...

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Thanks a lot. I provided libtorrent author with your backtrace. Now we just have to let him do his magic :)

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Apparently the break did not work.

Could you please try the following:
gdb qbittorrent
> break 120
Breakpoint 1 at 0x80b5e76: file main.cpp, line 120.
> run
... wait until it breaks
> catch throw (should work now that the program is loaded)
... wait until it catches a throw
> bt full
> c (to continue and make sure the throw was due to a bad_lexical_cast, if not, wait until it break again and type bt full again.)

Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :
Download full text (7.0 KiB)

In my binary function main has no line number information, so I used
break main (It seems the same).

it looks like the proper dump now, as I observe
...
#3 0x00000000004b640b in boost::lexical_cast<long, std::string> ()
#4 0x00007f78543969b4 in libtorrent::detail::bdecode_recursive<char const*> ()
   from /usr/lib64/libtorrent-rasterbar.so.2
...
----------------------------------------------------------------------
(gdb) break main
Breakpoint 1 at 0x479282
(gdb) run
Starting program: /home/archive/gitrepo/qbittorrent.git/qbittorrent/qbittorrent
[Thread debugging using libthread_db enabled]
[New Thread 140154793432912 (LWP 25652)]
[Switching to Thread 140154793432912 (LWP 25652)]

Breakpoint 1, 0x0000000000479282 in main ()
(gdb) catch throw
Catchpoint 2 (throw)
(gdb) continue
Continuing.
[New Thread 1086691648 (LWP 25655)]
[New Thread 1095084352 (LWP 25656)]
[New Thread 1103477056 (LWP 25661)]
[New Thread 1111869760 (LWP 25662)]
Catchpoint 2 (exception thrown)
0x00007f785265de30 in __cxa_throw () from /usr/lib64/libstdc++.so.6
(gdb) bt full
#0 0x00007f785265de30 in __cxa_throw () from /usr/lib64/libstdc++.so.6
No symbol table info available.
#1 0x00000000004b635a in boost::throw_exception<boost::bad_lexical_cast> ()
No symbol table info available.
#2 0x00000000004b63b5 in boost::detail::lexical_cast<long, std::string, false, char> ()
No symbol table info available.
#3 0x00000000004b640b in boost::lexical_cast<long, std::string> ()
No symbol table info available.
#4 0x00007f78543969b4 in libtorrent::detail::bdecode_recursive<char const*> ()
   from /usr/lib64/libtorrent-rasterbar.so.2
No symbol table info available.
#5 0x00007f7854396ce9 in libtorrent::bdecode<char const*> ()
   from /usr/lib64/libtorrent-rasterbar.so.2
No symbol table info available.
#6 0x00007f7854394ebe in libtorrent::http_tracker_connection::on_response ()
   from /usr/lib64/libtorrent-rasterbar.so.2
No symbol table info available.
#7 0x00007f7854395b2c in boost::_mfi::mf4<void, libtorrent::http_tracker_connection, boost::system::error_code const&, libtorrent::http_parser const&, char const*, int>::operator()<boost::intrusive_ptr<libtorrent::http_tracker_connection> > () from /usr/lib64/libtorrent-rasterbar.so.2
No symbol table info available.
#8 0x00007f7854395b82 in boost::_bi::bind_t<void, boost::_mfi::mf4<void, libtorrent::http_tracker_connection, boost::system::error_code const&, libtorrent::http_parser const&, char const*, int>, boost::_bi::list5<boost::_bi::value<boost::intrusive_ptr<libtorrent::http_tracker_connection> >, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4> > >::operator()<boost::system::error_code const, libtorrent::http_parser const, char const*, int, libtorrent::http_connection>
    () from /usr/lib64/libtorrent-rasterbar.so.2
No symbol table info available.
#9 0x00007f7854395ba7 in boost::detail::function::void_function_obj_invoker5<boost::_bi::bind_t<void, boost::_mfi::mf4<void, libtorrent::http_tracker_connection, boost::system::error_code const&, libtorrent::http_parser const&, char const*, int>, boost::_bi::list5<boost::_bi::value<boost::intrusive_ptr<libtorrent::http_tracker_connection> >, boost::arg<1>, boost::arg<2>...

Read more...

Changed in libtorrent-rasterbar:
status: New → Confirmed
Revision history for this message
Igor Vlasenko (viy-altlinux) wrote :

I've rebuilt qbittorrent with latest rasterbar svn (r3344) in 0_14 branch.
Everything seems to be ok, they do fixed the bug.

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Good news. I'm marking this bug as invalid since it does not affect qBittorrent itself.

Thank you for your report.

Changed in qbittorrent:
status: Triaged → Invalid
Changed in libtorrent-rasterbar:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.