Wait for DBus Reply Before Performing Computations
AbandonedPublic

Authored by narvaez on Feb 14 2019, 4:30 PM.

Details

Reviewers
bruns
astippich
poboiko
Group Reviewers
Baloo
Summary

If the scheduler has not replied by the time the batch size is used, the
default value is 0 and the mod operation results in a Floating Point
Exception.

I argue similar precautions are not needed for the call to
m_scheduler->getRemainingTime() in updateRemainingTime because the
default value of 0 will just lead to a confusing duration string but not
a crash.

Test Plan

To generate enough delay to witness the crash, you can simply attach a debugger to baloo_file and break on Baloo::FileIndexScheduler::getBatchSize (assuming you have debugging symbols for the baloo_file binary).

Diff Detail

Repository
R293 Baloo
Branch
newFile_crash
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 8296
Build 8314: arc lint + arc unit
narvaez created this revision.Feb 14 2019, 4:30 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptFeb 14 2019, 4:30 PM
Restricted Application added subscribers: Baloo, kde-frameworks-devel. · View Herald Transcript
narvaez requested review of this revision.Feb 14 2019, 4:30 PM
narvaez edited the test plan for this revision. (Show Details)Feb 14 2019, 4:38 PM
bruns added a comment.Feb 15 2019, 1:54 AM

good catch, but the fix is overengineered ...

src/qml/experimental/monitor.cpp
90

much more trivial:

auto updateInterval = std::max(100, 5 * m_scheduler->getBatchSize());
if (m_filesIndexed % updateInterval == 0) { ...
bruns requested changes to this revision.Feb 15 2019, 1:54 AM
This revision now requires changes to proceed.Feb 15 2019, 1:54 AM
davidedmundson added inline comments.
src/qml/experimental/monitor.cpp
90

That won't fix the issue.

getBatchSize is still returning a QDBusPendingReply, using the value before it's loaded will always be zero.

narvaez added inline comments.Feb 15 2019, 3:18 AM
src/qml/experimental/monitor.cpp
90

It does fix the issue because if getBatchSize returns 0 then updateInterval is set to 100. It does introduce another issue which is that it won't allow for an update interval under 100 (say, if the batch size was configurable in the future which is something you should really consider) but that is a minor issue compared to the crash this fixes.

bruns added inline comments.Feb 15 2019, 3:32 AM
src/qml/experimental/monitor.cpp
90

The batchsize 40 by default, so currently the update interval is 200 files. 100 or 200 does not matter to much, it is just a crude limiter anyway.

A better fix would be emit the remaining time directly from the scheduler, which could adapt much better to fast and slow progress. And listening to signals on DBus is in general preferable to querying.

narvaez added inline comments.Feb 15 2019, 10:28 AM
src/qml/experimental/monitor.cpp
90

The batch size is hardcoded at 40 so querying it at at any interval is pointless, for that matter. Instead of hardcoding more magic numbers I would just #define BATCH_SIZE 40 inside the Engine lib and set the update interval to 5 * BATCH_SIZE.

bruns added inline comments.Feb 15 2019, 3:03 PM
src/qml/experimental/monitor.cpp
90

Actually, both values are completely unrelated. They exist for similar reasons (commiting each file / updating the time for each file hurts performance). Just hardcoding e.g. 100 here would do.

narvaez abandoned this revision.Feb 17 2019, 12:03 PM