Bug 445437 - QML errors and crashing when removing processes with search open in tree view
Summary: QML errors and crashing when removing processes with search open in tree view
Status: RESOLVED FIXED
Alias: None
Product: plasma-systemmonitor
Classification: Applications
Component: general (show other bugs)
Version: 5.23.3
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-13 17:57 UTC by nyanpasu64
Modified: 2024-06-07 12:02 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Backtrace of this crash, missing many symbols. (3.36 KB, text/plain)
2021-11-13 17:57 UTC, nyanpasu64
Details
Screenshot of plasma-systemmonitor in a bugged state, with many processes missing names. (70.44 KB, image/png)
2021-11-15 21:36 UTC, nyanpasu64
Details
endRemoveRows warnings printed by plasma-systemmonitor (11.72 KB, text/plain)
2021-11-15 21:43 UTC, nyanpasu64
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nyanpasu64 2021-11-13 17:57:42 UTC
Created attachment 143517 [details]
Backtrace of this crash, missing many symbols.

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
When I run System Monitor, type a process name filter, and close a large number of processes matching the filter, switching to tree view produces QML errors and sometimes segfaults.

STEPS TO REPRODUCE
1. Open plasma-systemmonitor to the Processes tab.
2. Optionally switch to tree view.
3. Type bash into the search bar.
4. Open a Konsole tab, open Bash if you're using a different shell, and run `for i in {1..200}; do bash & done`.
5. Once the 200 bash processes show up in plasma-systemmonitor, close the Konsole tab, and wait for the processes to disappear.
6. Switch to tree view if you're not already in it. Warnings will not appear unless/until you're in tree view.

Without a search query open, I don't get instability (fixed in Bug 437862).

If you run a different child process (like perl), you can encounter this bug by searching for perl instead of bash. And if you start out in list view and later switch to tree view, you can *only* reproduce the bug by searching for perl (not the parent process bash).

OBSERVED RESULT

```
TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!
Model size of -1 is less than 0
Model size of -1 is less than 0
Model size of -1 is less than 0
...
file:///usr/lib/qt/qml/org/kde/ksysguard/table/TreeDecoration.qml:49: TypeError: Value is undefined and could not be converted to an object
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:57:42: Unable to assign [undefined] to bool
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:56:44: Unable to assign [undefined] to bool
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:55:39: Unable to assign [undefined] to int
file:///usr/lib/qt/qml/org/kde/ksysguard/table/TreeDecoration.qml:49: TypeError: Value is undefined and could not be converted to an object
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:57:42: Unable to assign [undefined] to bool
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:56:44: Unable to assign [undefined] to bool
file:///usr/lib/qt/qml/org/kde/ksysguard/table/FirstCellDelegate.qml:55:39: Unable to assign [undefined] to int
,,,
```

In some rare cases I get a crash as well. For example, when filtering in plasma-systemmonitor, I got a crash "in the wild" a few days ago with a non-symboled backtrace (attached), but it's missing the actual coredump. Since then, I've only been able to replicate this crash in synthetic conditions using non-symboled Arch Linux plasma-systemmonitor in painfully-slow Valgrind (my (!strip debug) builds don't crash).

EXPECTED RESULT
plasma-systemmonitor doesn't crash and doesn't use invalid object indexes.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.14.16-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: NVIDIA GeForce GT 730/PCIe/SSE2

ADDITIONAL INFORMATION
Comment 1 nyanpasu64 2021-11-15 21:36:44 UTC
Created attachment 143600 [details]
Screenshot of plasma-systemmonitor in a bugged state, with many processes missing names.

Apparently entering a filter is not necessary for plasma-systemmonitor to bug out.

- Open plasma-systemmonitor in a console.
- Switch to tree view but don't enter a filter.
- Run 200 perl processes.
- Scroll down until you see bash and the first 10-20 perl children.
- Close the bash tab.

nyanpasu64@ryzen ~> plasma-systemmonitor
kf.kirigami: Units.devicePixelRatio is deprecated (since 5.86): This returns 1 when using Qt HiDPI scaling.
file:///usr/lib/qt/qml/org/kde/ksysguard/table/TableViewHeader.qml:211: ReferenceError: heading is not defined (exception occurred during delayed function evaluation)
file:///usr/lib/qt/qml/org/kde/kirigami.2/private/globaltoolbar/ToolBarPageHeader.qml:83:13: QML Binding: Binding loop detected for property "value"
file:///usr/lib/qt/qml/org/kde/kirigami.2/private/globaltoolbar/ToolBarPageHeader.qml:88:13: QML Binding: Binding loop detected for property "value"
QAbstractItemModel::endRemoveRows:  Invalid index ( 198 , 3 ) in model ComponentCacheProxyModel(0x55ef5393eea0)
qt.core.qabstractitemmodel.checkindex: Index QModelIndex(-1,-1,0x0,QObject(0x0)) is not valid (expected valid)
file:///usr/share/ksysguard/sensorfaces/org.kde.ksysguard.processtable/contents/ui/ProcessTableView.qml:163:17: Unable to assign [undefined] to QString
Model size of -1 is less than 0
qt.core.qabstractitemmodel.checkindex: Index QModelIndex(-1,-1,0x0,QObject(0x0)) is not valid (expected valid)
file:///usr/share/ksysguard/sensorfaces/org.kde.ksysguard.processtable/contents/ui/ProcessTableView.qml:163:17: Unable to assign [undefined] to QString
Model size of -1 is less than 0
...
Comment 2 nyanpasu64 2021-11-15 21:43:59 UTC
Created attachment 143602 [details]
endRemoveRows warnings printed by plasma-systemmonitor

Note that this crash occurs inconsistently.

I retested where I slowly scrolled through the list of processes, making sure to load all 200 perl processes. Then when I closed the Konsole tab, the entire process list went empty, a few seconds later the terminal filled with "QAbstractItemModel::endRemoveRows:  Invalid index ( ### , 3 ) in model ComponentCacheProxyModel(0x5636510d77e0)" warnings (full log attached), then a few seconds later plasma-systemmonitor segfaulted.

However I tried a few more times. Sometimes the program seemed to work fine and unload the processes without any visible symptoms. One time it segfaulted anyway, without having printed errors beforehand.
Comment 3 Arjen Hiemstra 2024-06-07 12:02:07 UTC
For Plasma 6, we ported away from using KDescendantsProxyModel and use upstream TreeView now. This means the source of this crash is no longer used in System Monitor, so I am going to close this as fixed.