Giter VIP home page Giter VIP logo

Comments (2)

YakoYakoYokuYoku avatar YakoYakoYokuYoku commented on May 27, 2024 1

How do you know this? What observation are you making?

I know this because of debugging and using pop_alerts to check the order of arrival of alerts. During one test run I've perceived that a read_piece_alert for a piece arrived before its corresponding piece_finished_alert. If we see lt::piece_picker::has_piece_passed, which is called by lt::torrent::read_piece, we can notice that if we have downloaded (although not yet written) the piece pointed by index it returns true if the piece passed the hash check.

bool piece_picker::has_piece_passed(piece_index_t const index) const
{
TORRENT_ASSERT(index < m_piece_map.end_index());
TORRENT_ASSERT(index >= piece_index_t(0));
piece_pos const& p = m_piece_map[index];
if (p.index == piece_pos::we_have_index) return true;
auto const state = p.download_queue();
if (state == piece_pos::piece_open)
{
#if TORRENT_USE_ASSERTS
for (auto const i : categories())
TORRENT_ASSERT(find_dl_piece(i, index) == m_downloads[i].end());
#endif
return false;
}
auto const i = find_dl_piece(state, index);
TORRENT_ASSERT(i != m_downloads[state].end());
return bool(i->passed_hash_check);
}

But passed_hash_check is false nonetheless, even with disable_hash_checks, so the only thing that I can deduce is that read_piece is called first before doing the hash check. Besides from that I don't know.

Also, does it matter? you receive the data in the alert anyway, right? What else do you need?

Due to the piece failing the check if it has passed in lt::torrent::read_piece it gets cancelled and returns an invalid_piece_index error.

libtorrent/src/torrent.cpp

Lines 757 to 760 in 74bc93a

else if (!has_piece_passed(piece))
{
ec.assign(errors::invalid_piece_index, libtorrent_category());
}

Relevant to this I've generated a backtrace when it happened.

GDB backtrace of lt::torrent::read_piece
#0  libtorrent::torrent::read_piece (this=0x7ffff00659c0, piece=...) at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/torrent.cpp:748
#1  0x00007ffff68fae62 in libtorrent::torrent::remove_time_critical_piece (this=0x7ffff00659c0, piece=..., finished=true)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/torrent.cpp:5242
#2  0x00007ffff68f9cc6 in libtorrent::torrent::piece_passed (this=0x7ffff00659c0, index=...) at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/torrent.cpp:4416
#3  0x00007ffff68f98a0 in libtorrent::torrent::on_piece_verified (this=0x7ffff00659c0, block_hashes=..., piece=..., piece_hash=..., error=...)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/torrent.cpp:4125
#4  0x00007ffff68e413a in libtorrent::torrent::verify_piece (this=0x7ffff00659c0, piece=...) at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/torrent.cpp:11332
#5  0x00007ffff65e1aa5 in libtorrent::peer_connection::incoming_piece (this=0x7ffff03fe380, p=..., data=0x7ffff09905c9 "5x:*^'\237\326`KX")
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/peer_connection.cpp:3105
#6  0x00007ffff63455ff in libtorrent::bt_peer_connection::on_piece (this=0x7ffff03fe380, received=821)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/bt_peer_connection.cpp:1146
#7  0x00007ffff634aa27 in libtorrent::bt_peer_connection::dispatch_message (this=0x7ffff03fe380, received=821)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/bt_peer_connection.cpp:2152
#8  0x00007ffff63548ce in libtorrent::bt_peer_connection::on_receive_impl (this=0x7ffff03fe380, bytes_transferred=821)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/bt_peer_connection.cpp:3706
#9  0x00007ffff634ea9b in libtorrent::bt_peer_connection::on_receive (this=0x7ffff03fe380, error=..., bytes_transferred=821)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/bt_peer_connection.cpp:2753
#10 0x00007ffff65f2875 in libtorrent::peer_connection::on_receive_data (this=0x7ffff03fe380, error=..., bytes_transferred=821)
    at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/peer_connection.cpp:6213
#11 0x00007ffff66b0ee8 in libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<440ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage>::operator()<boost::system::error_code const&, unsigned long>
    (this=0x7ffff04daca0, a=..., a=@0x7ffff55ff950: 821) at /home/yakoyoku/Codes/CXX/Clones/libtorrent/include/libtorrent/aux_/allocating_handler.hpp:339
#12 0x00007ffff66b0e55 in std::__invoke_impl<void, libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<440ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage>&, boost::system::error_code const&, unsigned long> (__f=..., __args=..., __args=@0x7ffff55ff950: 821) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:61
#13 0x00007ffff66b0e05 in std::__invoke_r<void, libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<440ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage>&, boost::system::error_code const&, unsigned long>
    (__fn=..., __args=..., __args=@0x7ffff55ff950: 821) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:111
#14 0x00007ffff66b0cdd in std::_Function_handler<void (boost::system::error_code const&, unsigned long), libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<440ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage> >::_M_invoke(std::_Any_data const&, boost::system::error_code const&, unsigned long&&) (__functor=..., __args=..., __args=@0x7ffff55ff950: 821)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_function.h:290
#15 0x00007ffff6a86438 in std::function<void (boost::system::error_code const&, unsigned long)>::operator()(boost::system::error_code const&, unsigned long) const
    (this=0x7ffff55ffaf8, __args=..., __args=821) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_function.h:591
#16 0x00007ffff6a863c8 in std::__invoke_impl<void, std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&>(std::__invoke_other, std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&)
    (__f=..., __args=..., __args=@0x7ffff55ffb18: 821) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:61
#17 0x00007ffff6a86395 in std::__invoke_r<void, std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&>(std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&) (__fn=..., __args=..., __args=@0x7ffff55ffb18: 821)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:111
#18 0x00007ffff6a8634f in std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) (this=0x7ffff55ffaf8, __args=...)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/functional:654
#19 0x00007ffff6a862b3 in std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>::operator()<>() (this=0x7ffff55ffaf8) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/functional:713
#20 0x00007ffff6a861d5 in boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >::operator()() (this=0x7ffff55ffaf8) at /usr/include/boost/asio/detail/bind_handler.hpp:60
#21 0x00007ffff6a85f99 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >, boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> > >(boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >&, boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >&) (function=..., context=...)
    at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:51
#22 0x00007ffff6a86555 in boost::asio::detail::executor_op<boost::asio::detail::binder0<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >, std::allocator<void>, boost::asio::detail::scheduler_operation>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) (owner=0x555555562ea0, base=0x7ffff01cb860)
    at /usr/include/boost/asio/detail/executor_op.hpp:71
#23 0x00007ffff638f64e in boost::asio::detail::scheduler_operation::complete (this=0x7ffff01cb860, owner=0x555555562ea0, ec=..., bytes_transferred=0)
    at /usr/include/boost/asio/detail/scheduler_operation.hpp:40
#24 0x00007ffff638f07a in boost::asio::detail::scheduler::do_run_one (this=0x555555562ea0, lock=..., this_thread=..., ec=...)
    at /usr/include/boost/asio/detail/impl/scheduler.ipp:493
#25 0x00007ffff638eb5c in boost::asio::detail::scheduler::run (this=0x555555562ea0, ec=...) at /usr/include/boost/asio/detail/impl/scheduler.ipp:210
#26 0x00007ffff6387bff in boost::asio::io_context::run (this=0x555555abf530) at /usr/include/boost/asio/impl/io_context.ipp:64
#27 0x00007ffff67588b1 in libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0::operator()() const (this=0x55555595b088) at /home/yakoyoku/Codes/CXX/Clones/libtorrent/src/session.cpp:345
#28 0x00007ffff6758875 in std::__invoke_impl<void, libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0>(std::__invoke_other, libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0&&) (__f=...)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:61
#29 0x00007ffff6758835 in std::__invoke<libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0>(libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0&&) (__fn=...)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/invoke.h:96
#30 0x00007ffff675880d in std::thread::_Invoker<std::tuple<libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x55555595b088)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:292
#31 0x00007ffff67587e5 in std::thread::_Invoker<std::tuple<libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0> >::operator()() (this=0x55555595b088)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:299
#32 0x00007ffff6758689 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<libtorrent::session::start(libtorrent::flags::bitfield_flag<unsigned char, libtorrent::session_flags_tag, void>, libtorrent::session_params&&, boost::asio::io_context*)::$_0> > >::_M_run() (this=0x55555595b080)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/std_thread.h:244
#33 0x00007ffff58e1943 in std::execute_native_thread_routine (__p=0x55555595b080) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104
#34 0x00007ffff7a5255a in ??? () at /usr/lib/libc.so.6
#35 0x00007ffff7acfa3c in ??? () at /usr/lib/libc.so.6

from libtorrent.

arvidn avatar arvidn commented on May 27, 2024

The problem is that when read_piece_alert arrives it does it before a piece is done checking, so it's going to be an error even if disable_hash_checks is set to true.

How do you know this? What observation are you making?
Also, does it matter? you receive the data in the alert anyway, right? What else do you need?

from libtorrent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.