Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

division by zero #41

Closed
kdayns opened this issue Jul 29, 2013 · 3 comments
Closed

division by zero #41

kdayns opened this issue Jul 29, 2013 · 3 comments

Comments

@kdayns
Copy link

kdayns commented Jul 29, 2013

Iam running libtorrent 13.2 on some ARM SOC and experiencing pretty frequent crashes here:
#0 0xb6a92344 in raise () from /lib/libpthread.so.0
#1 0xb6aa4bc4 in __aeabi_ldiv0 () from /usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.6.3/libgcc_s.so.1
#2 0xb6dc1174 in torrent::FileList::chunk_index_size (this=0xd10160, index=0) at file_list.cc:169
#3 0xb6e4f72c in rak::const_mem_fun1<torrent::FileList, unsigned int, unsigned int>::operator() (this=0xd10124, a1=0) at ../../rak/functional.h:543
#4 0xb6e4eac8 in torrent::Delegator::new_chunk (this=0xd100c4, pc=0xee5080, highPriority=true) at delegator.cc:196
#5 0xb6e4e9e8 in torrent::Delegator::delegate_seeder (this=0xd100c4, peerChunks=0xee5080) at delegator.cc:180
#6 0xb6e4e5c8 in torrent::Delegator::delegate (this=0xd100c4, peerChunks=0xee5080, affinity=-1) at delegator.cc:138
#7 0xb6e95e00 in torrent::RequestList::delegate (this=0xee51c8) at request_list.cc:69
#8 0xb6e94ec0 in torrent::PeerConnectionMetadata::try_request_metadata_pieces (this=0xee5060) at peer_connection_metadata.cc:435
#9 0xb6e959f4 in torrent::PeerConnectionMetadata::fill_write_buffer (this=0xee5060) at peer_connection_metadata.cc:314
#10 0xb6e94530 in torrent::PeerConnectionMetadata::event_write (this=0xee5060) at peer_connection_metadata.cc:338
#11 0xb6d9d0fc in torrent::PollEPoll::perform (this=0xb92b88) at poll_epoll.cc:183
#12 0xb6d9d324 in torrent::PollEPoll::do_poll (this=0xb92b88, timeout_usec=437088, flags=0) at poll_epoll.cc:210
#13 0xb6e103bc in torrent::thread_base::event_loop (thread=0xb90c80) at thread_base.cc:145
#14 0x0003ab04 in main (argc=1, argv=0xbe9b9544) at main.cc:872

(gdb) frame 2
#2 0xb6dc1174 in torrent::FileList::chunk_index_size (this=0xd10160, index=0) at file_list.cc:169

(gdb) l
164 return left;
165 }
166
167 uint32_t
168 FileList::chunk_index_size(uint32_t index) const {
169 if (index + 1 != size_chunks() || size_bytes() % chunk_size() == 0)
170 return chunk_size();
171 else
172 return size_bytes() % chunk_size();
173 }
(gdb) call chunk_size()
$1 = 0
(gdb) frame 4
#4 0xb6e4eac8 in torrent::Delegator::new_chunk (this=0xd100c4, pc=0xee5080, highPriority=true) at delegator.cc:196

196 TransferList::iterator itr = m_transfers.insert(Piece(index, 0, m_slotChunkSize(index)), block_size);
(gdb) l
191 uint32_t index = m_slotChunkFind(pc, highPriority);
192
193 if (index == ~(uint32_t)0)
194 return NULL;
195
196 TransferList::iterator itr = m_transfers.insert(Piece(index, 0, m_slotChunkSize(index)), block_size);
197
198 (*itr)->set_by_seeder(pc->is_seeder());
199
200 if (highPriority)
(gdb) p index
$18 = 0
(gdb) p highPriority
$21 = true

(gdb) p pc
$19 = {m_peerInfo = 0xef8570, m_usingCounter = true, m_bitfield = {m_size = 1, m_set = 1, m_data = 0xedc718 "\200\325\247\266\270-\336"}, m_downloadCache = {static num_layers = 8, m_data = 0x0,
m_maxLayerSize = 0, m_index = 241, m_ceiling = 60464, m_layers = {{first = 0, second = 0}, {first = 0, second = 0}, {first = 0, second = 0}, {first = 0, second = 0}, {first = 0, second = 0}, {first = 0,
second = 0}, {first = 0, second = 0}, {first = 0, second = 0}}}, m_uploadQueue = empty std::list, m_cancelQueue = empty std::list, m_haveTimer = {m_time = 1374896674237079}, m_peerRate = {
m_container = std::deque with 0 elements, m_current = 0, m_total = 0, m_span = 600}, m_downloadThrottle = {m_quota = 0, m_listIterator = , m_rate = {m_container = std::deque with 0 elements,
m_current = 0, m_total = 0, m_span = 30}, m_slotActivate = {m_object = 0xee5068, m_function = (void (torrent::SocketBase::
)(
torrent::SocketBase * const)) 0xb6e6df18 torrent::SocketBase::receive_throttle_down_activate()}}, m_uploadThrottle = {m_quota = 0, m_listIterator = , m_rate = {m_container = std::deque with 0 elements,
m_current = 0, m_total = 0, m_span = 30}, m_slotActivate = {m_object = 0xee5068, m_function = (void (torrent::SocketBase::*)(
torrent::SocketBase * const)) 0xb6e6df6c torrent::SocketBase::receive_throttle_up_activate()}}}
(gdb)

(gdb) p ((FileList) m_slotChunkSize->m_object)
$15 = {<std::vector<torrent::File*, std::allocatortorrent::File* >> = std::vector of length 1, capacity 1 = {0xd110d0}, static open_no_create = 1, static open_require_all_open = 2, m_data = {m_hash = {
static size_data = 20, m_data = "s\031f\357z\310.\221^\353d\241Uk-\230\347\370\030\363"}, m_completed_bitfield = {m_size = 1, m_set = 0, m_data = 0xd0b210 ""}, m_untouched_bitfield = {m_size = 1,
m_set = 1, m_data = 0xd087b8 "\200\207\320"},
m_high_priority = {<std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int> > >> = std::vector of length 0, capacity 0, },
m_normal_priority = {<std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int> > >> = std::vector of length 1, capacity 1 = {{first = 0,
second = 1}}, }, m_wanted_chunks = 1, m_slot_initial_hash = {std::tr1::_Maybe_unary_or_binary_function = {}, std::tr1::_Function_base = {
static _M_max_size = 8, static _M_max_align = 4, _M_functor = {_M_unused = {_M_object = 0xd11058, _M_const_object = 0xd11058, _M_function_pointer = 0xd11058, _M_member_pointer = (
void (std::tr1::Undefined_class::)(std::tr1::_Undefined_class * const)) 0xd11058, this adjustment 6848476}, _M_pod_data = "X\020\321\000\270\377\320"},
_M_manager = 0x124894 <std::tr1::Function_base::Base_manager<std::tr1::Bind<std::tr1::Mem_fn<void (core::DownloadList::)(core::Download)> (core::DownloadList, core::Download)> >::_M_manager(std::tr1::_Any_data&, std::tr1::_Any_data const&, std::tr1::_Manager_operation)>},
M_invoker = 0x12486c <std::tr1::Function_handler<void (), std::tr1::Bind<std::tr1::Mem_fn<void (core::DownloadList::)(core::Download)> (core::DownloadList, core::Download)> >::_M_invoke(std::tr1::_Any_data const&)>}, m_slot_download_done = {std::tr1::_Maybe_unary_or_binary_function = {}, std::tr1::_Function_base = {static _M_max_size = 8, static _M_max_align = 4,
_M_functor = {_M_unused = {_M_object = 0xd319a0, _M_const_object = 0xd319a0, _M_function_pointer = 0xd319a0, _M_member_pointer = (void (std::tr1::Undefined_class::)(
std::tr1::_Undefined_class * const)) 0xd319a0, this adjustment 6848476}, _M_pod_data = "\240\031\323\000\270\377\320"},
_M_manager = 0x124894 <std::tr1::_Function_base::_Base_manager<std::tr1::Bind<std::tr1::Mem_fn<void (core::DownloadList::)(core::Download)> (core::DownloadList, core::Download)> >::_M_manager(std::tr1::_Any_data&, std::tr1::_Any_data const&, std::tr1::_Manager_operation)>},
_M_invoker = 0x12486c <std::tr1::_Function_handler<void (), std::tr1::Bind<std::tr1::Mem_fn<void (core::DownloadList::)(core::Download)> (core::DownloadList, core::Download)> >::_M_invoke(std::tr1::_Any_data const&)>}, m_slot_partially_done = {std::tr1::_Maybe_unary_or_binary_function = {}, std::tr1::_Function_base = {static _M_max_size = 8, static _M_max_align = 4,
_M_functor = {_M_unused = {_M_object = 0xa7d0b5e3, _M_const_object = 0xa7d0b5e3, _M_function_pointer = 0xa7d0b5e3, _M_member_pointer = &virtual table offset -1479494173, this adjustment 328511988},
_M_pod_data = "\343\265\320\247\351c)'"}, _M_manager = 0x0}, _M_invoker = 0x6421c774},
m_slot_partially_restarted = {std::tr1::_Maybe_unary_or_binary_function = {}, std::tr1::_Function_base = {static _M_max_size = 8, static _M_max_align = 4, _M_functor = {
_M_unused = {_M_object = 0xb1f78952, _M_const_object = 0xb1f78952, _M_function_pointer = 0xb1f78952, _M_member_pointer = &virtual table offset -1309177518, this adjustment 802265347},
M_pod_data = "R\211\367\261\a2\243"}, _M_manager = 0x0}, _M_invoker = 0x34b64eba}}, m_isOpen = true, m_torrentSize = 0, m_chunkSize = 0, m_maxFileSize = 137438953472, m_rootDir = "/download",
m_indirectLinks = std::vector of length 1, capacity 2 = {"/download"}, m_isMultiFile = false, m_frozenRootDir = "/download"}

(gdb) p ((((FileList*) m_slotChunkSize->m_object))[0])
$17 = {static flag_active = 1, static flag_create_queued = 2, static flag_resize_queued = 4, static flag_fallocate = 8, static flag_previously_created = 16, static flag_prioritize_first = 32,
static flag_prioritize_last = 64, m_fd = 8, m_protection = 1, m_flags = 21,
m_path = {<std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > >> = std::vector of length 1, capacity 1 = {"731966EF7AC82E915EEB64A1556B2D98E7F818F3.meta"}, m_encoding = ""}, m_frozenPath = "/download/731966EF7AC82E915EEB64A1556B2D98E7F818F3.meta", m_offset = 0, m_size = 0,
m_lastTouched = 1374896674479091, m_range = {first = 0, second = 0}, m_completed = 0, m_priority = torrent::PRIORITY_NORMAL, m_matchDepthPrev = 0, m_matchDepthNext = 0}

If you need more info just tell what to look up, this torrent is probably added from magnet link.

@kdayns
Copy link
Author

kdayns commented Jul 30, 2013

I may be wrong, but I think I tracked that the only way to get invalid(0) chunk_size is thru this function call path:
DownloadMain::set_metadata_size(size)
file_list()->reset_filesize(size);

I will try to reproduce with enabled logging.

@kdayns
Copy link
Author

kdayns commented Aug 29, 2013

I was rigth, got it again, with logging enabled, and last lines read:
1377651261 I 731966EF7AC82E915EEB64A1556B2D98E7F818F3->file_list: Resetting torrent size: size:0.
1377651261 I 731966EF7AC82E915EEB64A1556B2D98E7F818F3->file_list: Closing.
1377651261 I 731966EF7AC82E915EEB64A1556B2D98E7F818F3->file_list: Opening.

@rakshasa
Copy link
Owner

Closing as the version is too old

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants