ASSERT: "first <= last" in file src/base/indexrange.h, line 45 #8658

Closed
opened 2026-02-21 19:44:30 -05:00 by deekerman · 6 comments
Owner

Originally created by @Golutazem on GitHub (May 9, 2019).

Debug build compiled from Git Head checked out today.
GNU+Linux+Xorg with Qt 5.12.3 , libtorrent-rasterbar 1:1.1.12

Steps to reproduce

Add a torrent file from the file select dialogue.
Resulted in
ASSERT: "first <= last" in file src/base/indexrange.h, line 45

BackTrace:
#2 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
#3 in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
#4 in IndexInterval::IndexInterval (last=3506, first=3507, this=) at /usr/include/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp:125
#5 makeInterval (last=3506, first=3507) at src/base/indexrange.h:66
#6 BitTorrent::TorrentInfo::filePieces (this=this@entry=0x7fffffffd1f0, fileIndex=fileIndex@entry=4682)
at src/base/bittorrent/torrentinfo.cpp:368
#7 in BitTorrent::TorrentHandle::setFirstLastPiecePriorityImpl (this=this@entry=0x5555607ca410, enabled=false, updatedFilePrio=...)
at src/base/bittorrent/torrenthandle.cpp:1394
#8 in BitTorrent::TorrentHandle::setFirstLastPiecePriority (this=this@entry=0x5555607ca410, enabled=) at /usr/include/qt/QtCore/qarraydata.h:257
#9 in BitTorrent::TorrentHandle::TorrentHandle (this=0x5555607ca410, session=, nativeHandle=..., params=...)
at src/base/bittorrent/torrenthandle.cpp:206
#10 in BitTorrent::Session::createTorrentHandle (this=0x5555561ae1e0, nativeHandle=...)
at src/base/bittorrent/session.cpp:3842
#11 in BitTorrent::Session::handleAddTorrentAlert (this=this@entry=0x5555561ae1e0, p=p@entry=0x7fff72e7d2e8)
at src/base/bittorrent/session.cpp:3899
#12 in BitTorrent::Session::handleAlert (this=this@entry=0x5555561ae1e0, a=0x7fff72e7d2e8)
at src/base/bittorrent/session.cpp:3786
#13 in BitTorrent::Session::readAlerts (this=0x5555561ae1e0) at src/base/bittorrent/session.cpp:3748
#14 in BitTorrent::Session::qt_static_metacall (_o=, _c=, _id=, _a=)
at Build/src/base/qbt_base_autogen/VKOXE6AELE/moc_session.cpp:393
#15 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5
#16 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#17 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#18 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#19 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
#20 in ?? () from /usr/lib/libQt5Core.so.5
#21 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#22 in ?? () from /usr/lib/libglib-2.0.so.0
#23 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#24 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQt5Core.so.5
#25 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQt5Core.so.5
#26 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#27 in Application::exec (this=0x5555560c7340, params=...) at src/app/application.cpp:572
#28 in main (argc=, argv=) at src/app/main.cpp:252

Originally created by @Golutazem on GitHub (May 9, 2019). Debug build compiled from Git Head checked out today. GNU+Linux+Xorg with Qt 5.12.3 , libtorrent-rasterbar 1:1.1.12 ### Steps to reproduce Add a torrent file from the file select dialogue. Resulted in ASSERT: "first <= last" in file src/base/indexrange.h, line 45 BackTrace: #2 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5 #3 in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5 #4 in IndexInterval<int>::IndexInterval (last=3506, first=3507, this=<optimized out>) at /usr/include/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp:125 #5 makeInterval<int> (last=3506, first=3507) at src/base/indexrange.h:66 #6 BitTorrent::TorrentInfo::filePieces (this=this@entry=0x7fffffffd1f0, fileIndex=fileIndex@entry=4682) at src/base/bittorrent/torrentinfo.cpp:368 #7 in BitTorrent::TorrentHandle::setFirstLastPiecePriorityImpl (this=this@entry=0x5555607ca410, enabled=false, updatedFilePrio=...) at src/base/bittorrent/torrenthandle.cpp:1394 #8 in BitTorrent::TorrentHandle::setFirstLastPiecePriority (this=this@entry=0x5555607ca410, enabled=<optimized out>) at /usr/include/qt/QtCore/qarraydata.h:257 #9 in BitTorrent::TorrentHandle::TorrentHandle (this=0x5555607ca410, session=<optimized out>, nativeHandle=..., params=...) at src/base/bittorrent/torrenthandle.cpp:206 #10 in BitTorrent::Session::createTorrentHandle (this=0x5555561ae1e0, nativeHandle=...) at src/base/bittorrent/session.cpp:3842 #11 in BitTorrent::Session::handleAddTorrentAlert (this=this@entry=0x5555561ae1e0, p=p@entry=0x7fff72e7d2e8) at src/base/bittorrent/session.cpp:3899 #12 in BitTorrent::Session::handleAlert (this=this@entry=0x5555561ae1e0, a=0x7fff72e7d2e8) at src/base/bittorrent/session.cpp:3786 #13 in BitTorrent::Session::readAlerts (this=0x5555561ae1e0) at src/base/bittorrent/session.cpp:3748 #14 in BitTorrent::Session::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at Build/src/base/qbt_base_autogen/VKOXE6AELE/moc_session.cpp:393 #15 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5 #16 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #17 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #18 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5 #19 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5 #20 in ?? () from /usr/lib/libQt5Core.so.5 #21 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #22 in ?? () from /usr/lib/libglib-2.0.so.0 #23 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #24 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5 #25 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5 #26 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5 #27 in Application::exec (this=0x5555560c7340, params=...) at src/app/application.cpp:572 #28 in main (argc=<optimized out>, argv=<optimized out>) at src/app/main.cpp:252
Author
Owner

@Chocobo1 commented on GitHub (May 9, 2019):

This line looks weird to me:
https://github.com/qbittorrent/qBittorrent/blob/master/src/base/bittorrent/torrentinfo.cpp#L368
Can you try removing - 1 in that line and retest again?

@Chocobo1 commented on GitHub (May 9, 2019): This line looks weird to me: https://github.com/qbittorrent/qBittorrent/blob/master/src/base/bittorrent/torrentinfo.cpp#L368 Can you try removing `- 1` in that line and retest again?
Author
Owner

@Golutazem commented on GitHub (May 10, 2019):

I made that change and retried. I see no sign of error, though I do not understand from the change what I should look for.

@Golutazem commented on GitHub (May 10, 2019): I made that change and retried. I see no sign of error, though I do not understand from the change what I should look for.
Author
Owner

@Chocobo1 commented on GitHub (May 10, 2019):

though I do not understand from the change what I should look for.

Whether qbt still dump the back trace when you add the same torrent as in your opening post. If none then it is good.

I'm afraid I'll need more info before making a good fix, could you modify the code segment as below:

const libt::file_storage &files = nativeInfo()->files();
const auto fileSize = files.file_size(LTFileIndex {fileIndex});
const auto fileOffset = files.file_offset(LTFileIndex {fileIndex});
printf("fileOffset: %ld\n", fileOffset);
printf("pieceLength: %d\n", pieceLength());
printf("fileSize : %ld\n", fileSize);
return makeInterval(static_cast<int>(fileOffset / pieceLength()),
    static_cast<int>((fileOffset + fileSize - 1) / pieceLength()));

Insert the 3 printf lines and compile again, then add the same torrent file as you did in the opening post, the console will print some text & values, please post them here.

Or if possible, you can share the torrent hash.

@Chocobo1 commented on GitHub (May 10, 2019): >though I do not understand from the change what I should look for. Whether qbt still dump the back trace when you add the same torrent as in your opening post. If none then it is good. I'm afraid I'll need more info before making a good fix, could you modify the code segment as below: ```c++ const libt::file_storage &files = nativeInfo()->files(); const auto fileSize = files.file_size(LTFileIndex {fileIndex}); const auto fileOffset = files.file_offset(LTFileIndex {fileIndex}); printf("fileOffset: %ld\n", fileOffset); printf("pieceLength: %d\n", pieceLength()); printf("fileSize : %ld\n", fileSize); return makeInterval(static_cast<int>(fileOffset / pieceLength()), static_cast<int>((fileOffset + fileSize - 1) / pieceLength())); ``` Insert the 3 `printf` lines and compile again, then add the same torrent file as you did in the opening post, the console will print some text & values, please post them here. Or if possible, you can share the torrent hash.
Author
Owner

@Golutazem commented on GitHub (May 10, 2019):

Adding the torrent file again did not cause an error. All appears to run normally afterwards. I continue to run in GDB. If I encounter an error that appears related, I will re-open the issue.

@Golutazem commented on GitHub (May 10, 2019): Adding the torrent file again did not cause an error. All appears to run normally afterwards. I continue to run in GDB. If I encounter an error that appears related, I will re-open the issue.
Author
Owner

@Chocobo1 commented on GitHub (May 10, 2019):

@Golutazem
Do you mind follow the instructions in https://github.com/qbittorrent/qBittorrent/issues/10611#issuecomment-491236061? I don't think it is properly fixed.

@Chocobo1 commented on GitHub (May 10, 2019): @Golutazem Do you mind follow the instructions in https://github.com/qbittorrent/qBittorrent/issues/10611#issuecomment-491236061? I don't think it is properly fixed.
Author
Owner

@Golutazem commented on GitHub (May 10, 2019):

Sorry. I no longer have the file or the hash and could not identify it again. I have added the diagnostic output to the build so that if it occurs again I can give more output.

@Golutazem commented on GitHub (May 10, 2019): Sorry. I no longer have the file or the hash and could not identify it again. I have added the diagnostic output to the build so that if it occurs again I can give more output.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#8658
No description provided.