miguelfreitas / twister-core

twister core / daemon
MIT License
1.42k stars 251 forks source link

Crash - assertion failed. #429

Open centaur1 opened 6 years ago

centaur1 commented 6 years ago

This happens reasonably often.

assertion failed. Please file a bugreport at https://github.com/miguelfreitas/twister-core/issues Please include the following information:

version: 1.0.0.0 $Rev: 7680 $ file: 'libtorrent/src/torrent.cpp' line: 3066 function: void libtorrent::torrent::piece_finished(int, int, boost::uint32_t, int) expression: !m_picker->have_piece(index)

stack: 1: assert_fail(char const, int, char const, char const, char const) 2: libtorrent::torrent::piece_finished(int, int, unsigned int, int) 3: boost::detail::function::void_function_obj_invoker2<boost::_bi::bind_t<void, boost::_mfi::mf4<void, libtorrent::torrent, int, int, unsigned int, int>, boost::_bi::list5<boost::_bi::value<boost::shared_ptr >, boost::_bi::value, boost::arg<1>, boost::arg<2>, boost::_bi::value > >, void, int, unsigned int>::invoke(boost::detail::function::function_buffer&, int, unsigned int) 4: libtorrent::torrent::on_piece_verified(int, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)>) 5: void boost::_mfi::mf3<void, libtorrent::torrent, int, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)> >::call<boost::shared_ptr, int, libtorrent::disk_io_job const, boost::function<void (int, unsigned int)> >(boost::shared_ptr&, void const, int&, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)>&) const 6: void boost::_bi::list4<boost::_bi::value<boost::shared_ptr >, boost::arg<1>, boost::arg<2>, boost::_bi::value<boost::function<void (int, unsigned int)> > >::operator()<boost::_mfi::mf3<void, libtorrent::torrent, int, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)> >, boost::_bi::list2<int&, libtorrent::disk_io_job const&> >(boost::_bi::type, boost::_mfi::mf3<void, libtorrent::torrent, int, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)> >&, boost::_bi::list2<int&, libtorrent::disk_io_job const&>&, int) 7: boost::detail::function::void_function_obj_invoker2<boost::_bi::bind_t<void, boost::_mfi::mf3<void, libtorrent::torrent, int, libtorrent::disk_io_job const&, boost::function<void (int, unsigned int)> >, boost::_bi::list4<boost::_bi::value<boost::shared_ptr >, boost::arg<1>, boost::arg<2>, boost::_bi::value<boost::function<void (int, unsigned int)> > > >, void, int, libtorrent::disk_io_job const&>::invoke(boost::detail::function::function_buffer&, int, libtorrent::disk_io_job const&) 8: libtorrent::completion_queue_handler(std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >) 9: void boost::asio::asio_handler_invoke<boost::_bi::bind_t<void, void ()(std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >), boost::_bi::list1<boost::_bi::value<std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >> > > >(boost::_bi::bind_t<void, void ()(std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >), boost::_bi::list1<boost::_bi::value<std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >> > >&, ...) 10: boost::asio::detail::completion_handler<boost::_bi::bind_t<void, void ()(std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >), boost::_bi::list1<boost::_bi::value<std::1::list<std::1::pair<libtorrent::disk_io_job, int>, std::1::allocator<std::1::pair<libtorrent::disk_io_job, int> > >> > > >::do_complete(void, boost::asio::detail::scheduler_operation, boost::system::error_code const&, unsigned long) 11: boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) 12: boost::asio::detail::scheduler::run(boost::system::error_code&) 13: boost::asio::io_context::run(boost::system::error_code&) 14: libtorrent::aux::session_impl::main_thread() 15: boost::asio::detail::posix_thread::func<boost::_bi::bind_t<void, boost::_mfi::mf0<void, libtorrent::aux::session_impl>, boost::_bi::list1<boost::_bi::value<libtorrent::aux::session_impl> > > >::run() 16: boost_asio_detail_posix_thread_function 17: _pthread_body 18: _pthread_body 19: thread_start

centaur1 commented 6 years ago

The way to duplicate this is if you do this: If twisterd has returned null from something like this: /usr/name/twister-core/twisterd getposts 1 '[{"username":"whateveruser"}]' [ ]

and then you attempt to do a post like this: /usr/name/twister-core/twisterd newpostmsg whateveruser 1 'something here https://google.com'

It will crash as above. I've duplicated it about a dozen times so far with tests. I presume it is because it is busy fetching information on that user, hence the "!m_picker->have_piece(index)"

In short, if someone tries to post for a particular user while it is still fetching for that particular user, it crashes from my testing.

So one can mitigate it by checking to see if NULL is returned from a twisterd call checking a user prior to attempting to post their post. It shouldn't crash of course, but at least one can check for the condition prior to doing a post.

In case anyone else sees that, at least it can be mitigated.

centaur1 commented 6 years ago

What I ended up doing besides just checking it is to programmatically do a unfollow <username> '["<username>"]' followed by a follow ... as above

This seems to be the same error as is checked in the html interface with the message: Internal error: lastPostId unknown (following yourself may fix!)": "Internal error: lastPostId unknown (following yourself may fix!)

miguelfreitas commented 6 years ago

Hi @centaur1. Thank you very much for your investigation! It is great that you have found a way to reproduce it, as it makes fixing a much easier job :-) I just can't promise when I'll be able to look into that issue because I'm quite busy at work these days...

centaur1 commented 6 years ago

If I can dig more into the code, I'll post it here. It seems to be really two related issues:

  1. The assertion issue.
  2. The "Internal error: lastPostId unknown" that is found in twister-html.

I think they are related in that if the lastPostId is unknown (the torrent hasn't been fetched yet either) then one would be using an incorrect K value.

My "fix" was doing a dhtget, unfollow, and then follow.

I am not sure about all that though since I am still progressing on it.