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

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

Closed
Golutazem opened this issue May 9, 2019 · 6 comments · Fixed by #10638
Closed

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

Golutazem opened this issue May 9, 2019 · 6 comments · Fixed by #10638
Milestone

Comments

@Golutazem
Copy link

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

@Chocobo1 Chocobo1 added this to the 4.2.0 milestone May 9, 2019
@Chocobo1
Copy link
Member

Chocobo1 commented 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?

@Golutazem
Copy link
Author

Golutazem commented 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.

@Chocobo1
Copy link
Member

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.

@Golutazem
Copy link
Author

Golutazem commented 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.

@Chocobo1
Copy link
Member

@Golutazem
Do you mind follow the instructions in #10611 (comment)? I don't think it is properly fixed.

@Golutazem
Copy link
Author

Golutazem commented 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.

Chocobo1 added a commit to Chocobo1/qBittorrent that referenced this issue May 15, 2019
When fileSize == 0, the second index could be smaller than the first index,
thus trigger the assert check in IndexInterval constructor.

Closes qbittorrent#10611.
Chocobo1 added a commit to Chocobo1/qBittorrent that referenced this issue May 16, 2019
When fileSize == 0, the second index could be smaller than the first index,
thus trigger the assert check in IndexInterval constructor.

Closes qbittorrent#10611.
@qbittorrent qbittorrent locked and limited conversation to collaborators Feb 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants