Bug 445342

Summary: Apps using Milou.ResultsView crash on exit
Product: [Frameworks and Libraries] frameworks-krunner Reporter: Bharadwaj Raju <bharadwaj.raju777>
Component: generalAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED FIXED    
Severity: crash CC: nate
Priority: NOR    
Version: 5.87.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Backtrace
Test QML app, run with qmlscene

Description Bharadwaj Raju 2021-11-11 14:57:20 UTC
Created attachment 143452 [details]
Backtrace

SUMMARY
Apps using Milou.ResultsView crash on exit. I noticed this while testing https://invent.kde.org/plasma/kwin/-/merge_requests/1642, and could reproduce it with a simple QML app too (attached). I can do multiple searches and keep it open indefinitely, but exiting crashes it.

Is this wrong usage of ResultsView?

Backtrace attached.

STEPS TO REPRODUCE
1. Open an app or desktop effect which uses Milou
2. Exit

OBSERVED RESULT
App crashes

EXPECTED RESULT
App exits normally

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-38-generic (64-bit)
Graphics Platform: Wayland
Comment 1 Bharadwaj Raju 2021-11-11 14:58:39 UTC
Created attachment 143453 [details]
Test QML app, run with qmlscene
Comment 2 Alexander Lohnau 2021-11-11 16:41:30 UTC
Interesting, I get a different issue with the app not exiting & a warning about deleting a locked mutex. 

I will investigate.
Comment 3 Bharadwaj Raju 2021-11-11 16:45:00 UTC
It prints the mutex warning for me too.

"QMutex: destroying locked mutex"

Also it seems the crash only happens if I close the app within a short time of typing something. If I let it sit for a while then close it, it closes fine (although the process takes a while to exit). My guess is that this happens if the app exits while some runner (appears to be Baloo in this case) is still processing?
Comment 4 Alexander Lohnau 2021-11-12 08:13:26 UTC
Actually it seems to be a problem with KRunner too, though it for sure worked fine for as long as I can remember.

it is reproducible by typing sth. in KRunner and then running `kquitapp5 krunner`

I even tried to go back some KRunner frameworks version with no effect :/
Comment 5 Alexander Lohnau 2021-11-12 08:35:19 UTC
I have a fix locally, for the memory related issues.

The root problem is the baloo runner taking forever and thus triggering the edge cases, in my case I have disabled the baloo desktop search but not the KRunner plugin.
Comment 6 Bug Janitor Service 2021-11-12 10:22:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1197
Comment 7 Alexander Lohnau 2021-11-16 10:34:10 UTC
Git commit fa5ac3fe3421a0077d9d80f52b89536daa732afa by Alexander Lohnau.
Committed on 16/11/2021 at 10:00.
Pushed by alex into branch 'master'.

baloosearchruner: Emit DBus error when baloo is disabled

Otherwise we exit and KRunner runner into a long timeout.

By making this a dedicated DBus error KRunner can also know, that this
runner can not be started. Consequently making new attempts to query
this runner can be prevented.

Because the runner is DBus-Activated, we can not exit the process, otherwise other
processes (like the search in the app launcher) will have the same issue with the timeout.

M  +10   -4    runners/baloo/baloosearchrunner.cpp
M  +1    -1    runners/baloo/baloosearchrunner.h

https://invent.kde.org/plasma/plasma-workspace/commit/fa5ac3fe3421a0077d9d80f52b89536daa732afa
Comment 8 Alexander Lohnau 2021-11-16 10:39:48 UTC
Git commit 06fa9fae498a5a6822fefd02b743e9591e9ebe13 by Alexander Lohnau.
Committed on 16/11/2021 at 10:39.
Pushed by alex into branch 'cherry-pick-fa5ac3fe'.

baloosearchruner: Emit DBus error when baloo is disabled

Otherwise we exit and KRunner runner into a long timeout.

By making this a dedicated DBus error KRunner can also know, that this
runner can not be started. Consequently making new attempts to query
this runner can be prevented.

Because the runner is DBus-Activated, we can not exit the process, otherwise other
processes (like the search in the app launcher) will have the same issue with the timeout.


(cherry picked from commit fa5ac3fe3421a0077d9d80f52b89536daa732afa)

M  +10   -4    runners/baloo/baloosearchrunner.cpp
M  +1    -1    runners/baloo/baloosearchrunner.h

https://invent.kde.org/plasma/plasma-workspace/commit/06fa9fae498a5a6822fefd02b743e9591e9ebe13
Comment 9 Alexander Lohnau 2021-11-16 10:40:58 UTC
Git commit afff43effadd78ab682ecf4c6c9919bdcbbedbcd by Alexander Lohnau.
Committed on 16/11/2021 at 10:40.
Pushed by alex into branch 'Plasma/5.23'.

baloosearchruner: Emit DBus error when baloo is disabled

Otherwise we exit and KRunner runner into a long timeout.

By making this a dedicated DBus error KRunner can also know, that this
runner can not be started. Consequently making new attempts to query
this runner can be prevented.

Because the runner is DBus-Activated, we can not exit the process, otherwise other
processes (like the search in the app launcher) will have the same issue with the timeout.


(cherry picked from commit fa5ac3fe3421a0077d9d80f52b89536daa732afa)

M  +10   -4    runners/baloo/baloosearchrunner.cpp
M  +1    -1    runners/baloo/baloosearchrunner.h

https://invent.kde.org/plasma/plasma-workspace/commit/afff43effadd78ab682ecf4c6c9919bdcbbedbcd