-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Disable processing socket events in findIncompleteFiles() #7445
Conversation
Could you explain, please, why this is needed? Don't understand neither this change nor the mentioned bda5be8. |
You will need to see the crash report in #7327. |
Thank you. Don't understand anyway why and how |
due to |
I still can't make any sense out of it :(. Why did it crash? What are the other kind of events that you want to process in the loop inside |
Thread safety issues? ¯\(ツ)/¯
No solid idea either, although I suspect some GUI painting events to make qbt appear active. |
Ok. Let's see the following sequence:
Something like this... Maybe I missed some details, or mixed up something, but the GENERAL MEANING should be clear. |
Thanks for the explanations! Just one more question: why can't this be solved by disabling the dialog in |
This can be a good idea in itself. But we cannot ensure that more than one "button click" event will not appear in the queue before the first of them will begin to be processed. |
Now I've a new view on the stack dump in #7436. It's happening a lot in these few lines I believe:
Some background: A webUI socket connect will disconnect after 7 sec of idleness, see: https://github.com/qbittorrent/qBittorrent/blob/master/src/base/http/server.cpp#L64
Now I think adding |
I don't like processEvents here too. The only its goal is to prevent GUI freezing when user adding torrent with many files. |
Or maybe enable if (!webUIEnabled())
qApp->processEvents(QEventLoop::ExcludeUserInputEvents); |
c8992f6
to
0ba4a5e
Compare
PR updated. |
src/base/bittorrent/session.cpp
Outdated
@@ -2217,7 +2219,7 @@ bool Session::findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) c | |||
found = true; | |||
torrentInfo.renameFile(i, filePath + QB_EXT); | |||
} | |||
if ((i % 100) == 0) | |||
if (!isWebUIEnabled && ((i % 100) == 0)) // mitigate webAPI connection might timeout and result in use-after-free sigfault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sEgfault
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fixed in commit msg, thank you.
I think we should get rid of it at all. This can be a source of some hard to find errors. E.g. when we run the application, we must first renew all the existing torrents, and nothing should interfere in this process. How can we ensure this? Besides, it affects only torrents with really many files (I think they should be in the thousands). |
And yet... Your solution creates an unacceptable dependency (core shouldn't be dependent from the user interface). |
webUI connection timeout & deletion might occur while doing processEvents() and will result in use-after-free segfault.
0ba4a5e
to
f3603d0
Compare
OK, PR updated. |
If no one objects it, I'll merge it after waiting 24hrs. |
Just a question: why nobody discusses a multi-threaded approach? |
I thought about it. Maybe later, unless someone want to do it too. |
|
Everyone thank you! |
Related to bda5be8, but this time is from webUI.