| Summary: | Setting Kirigami.FormData.buddyFor to a null item crashes the calling app | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-kirigami | Reporter: | Armando S. Araujo <aee_eletronica> |
| Component: | general | Assignee: | kdelibs bugs <kdelibs-bugs-null> |
| Status: | ASSIGNED --- | ||
| Severity: | crash | CC: | aee_eletronica, nate, notmart |
| Priority: | NOR | Keywords: | drkonqi |
| Version First Reported In: | 5.105.0 | ||
| Target Milestone: | Not decided | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | New crash information added by DrKonqi | ||
|
Description
Armando S. Araujo
2023-04-20 11:50:00 UTC
Thank you for the bug report! Unfortunately I can't reproduce the crash myself on current git master, and the backtrace is incomplete and missing debug symbols for the following lines that we need to figure out exactly what's going wrong: > #18 0x00007f9b300a0b67 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/plasma/kcms/systemsettings/kcm_landingpage.so > #19 0x00007f9b48fc85c7 in ?? () from /lib/x86_64-linux-gnu/libKF5KCMUtils.so.5 > #20 0x00007f9b48fc85ed in ?? () from /lib/x86_64-linux-gnu/libKF5KCMUtils.so.5 Could you please install debug symbols for Plasma, reproduce the crash, and attach a new symbolicated backtrace? See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports for details about how to do this. Thanks again! Created attachment 158395 [details]
New crash information added by DrKonqi
systemsettings (5.27.4) using Qt 5.15.9
armando@florest-1:/home$ systemsettings
file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/ScrollablePage.qml:200:9: QML MouseArea: Binding loop detected for property "width"
file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/ScrollablePage.qml:200:9: QML MouseArea: Binding loop detected for property "width"
kf.activitiesstats: [Error at ResultSetPrivate::initQuery]: QSqlError("11", "Não foi possível obter a linha", "database disk image is malformed")
kf.activitiesstats: [Error at ResultSetPrivate::initQuery]: QSqlError("11", "Não foi possível obter a linha", "database disk image is malformed")
QQmlEngine::setContextForObject(): Object already has a QQmlContext
file:///usr/share/kpackage/kcms/kcm_landingpage/contents/ui/main.qml:197:13: Unable to assign [undefined] to
QQuickItem*
KCrash: crashing... crashRecursionCounter = 2
KCrash: Application Name = systemsettings path = /usr/bin pid = 36617
KCrash: Arguments: /usr/bin/systemsettings
KCrash: Attempting to start /usr/lib/x86_64-linux-gnu/libexec/drkonqi
[1]+ Parado systemsettings
armando@florest-1:/home$ Unable to find file for pid 36617 expected at "kcrash-metadata/36617.ini"
QSocketNotifier: Invalid socket 6 and type 'Read', disabling...
QSocketNotifier: Invalid socket 10 and type 'Read', disabling...
QSocketNotifier: Invalid socket 20 and type 'Read', disabling...
-- Backtrace (Reduced):
#7 0x00007f37c0fdf2f7 in QAccessibleQuickItem::role() const () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
[...]
#11 0x00007f37c0e61dbb in QQuickItemPrivate::setEffectiveVisibleRecur(bool) () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
#12 0x00007f37c0e69686 in QQuickItem::setParentItem(QQuickItem*) () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
#13 0x00007f37c0e69bd1 in QQuickItem::~QQuickItem() () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
[...]
#15 0x00007f37c1ed04ba in KDeclarative::QmlObject::~QmlObject() () from /lib/x86_64-linux-gnu/libKF5Declarative.so.5
Ok, so here's what appears to be happening. Your activities database has become corrupted:
> kf.activitiesstats: [Error at ResultSetPrivate::initQuery]: QSqlError("11", "Não foi possível obter a linha", "database disk image is malformed")
This causes the grid of "Frequently used" pages to not be populated. Then when we try to set the buddy for the label to the grid's first child item, it crashes because there are no child items. Because that page is the thing that gets shown when System Settings launches, it crashes on launch.
Looks like Kirigami.FormLayout doesn't handle the case of the object specified by Kirigami.FormData.buddyFor being null. We could work around this in the code for the Quick Settings page, but ideally it would be fixed in Kirigami so that app-specific workarounds aren't ever required anywhere.
Armando, you should be able to fix this yourself by deleting your kactivities database and letting it get re-created. Delete `~/.local/share/kactivitymanagerd/resources/database*` on your system and then System Settings shouldn't crash anymore.
Finally, if you can attach ~/.local/share/kactivitymanagerd/resources/errors.log, we may be able to see what happened to the database.
Not gonna lie, this is the most cursed thing I've seen with FormLayouts:
> Kirigami.FormData.buddyFor: children[1] // 0 is the Repeater
The whole grid and repeater there are kinda questionable.
The "widest button" property is a perfect use-case for a SizeGroup type. And the "first item" should be extracted in a procedural code, like in a onItemAdded hook or something. The conditional logic for visibily (visible: recentlyUsedRepeater.count) does not inspire confidence either: what if a Repeater decides not to create items unless it becomes visible?
Speaking of buddyFor crash, this setter's implementation doesn't seem to guard against null member, does it?
void FormLayoutAttached::setBuddyFor(QQuickItem *buddyfor)
{
if (m_buddyFor == buddyfor || !m_buddyFor->isAncestorOf(buddyfor)) {
return;
}
m_buddyFor = buddyfor;
Q_EMIT buddyForChanged();
}
I believe this only ever worked because `isAncestorOf` method does not use ANY members of *this* object, and instead calls its argument's methods and comparent with *this* as a pointer.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1490 OK, so Landing Page UI itself it getting fixed in the best way we can. Meanwhile, I verified that the condition in `FormLayoutAttached::setBuddyFor` itself is buggy, play around with this snippet and insert some debug prints in Kirigami to verify yourself: https://invent.kde.org/frameworks/kirigami/-/snippets/2625 Git commit 3bc36d5f2380a7df3dfe390813a61944b43bf00d by ivan tkachenko. Committed on 26/04/2023 at 14:38. Pushed by ratijas into branch 'master'. landingpage: Fix broken binding in "Most Used Pages" grid First rule of the fighting club: never bind to a list. You never know what the heck you're up against. On the other hand, assigning FormData.buddyFor in a procedural way in the Repeater's hook is robust, and there's nothing that could go wrong. M +8 -1 kcms/landingpage/package/contents/ui/main.qml https://invent.kde.org/plasma/plasma-desktop/commit/3bc36d5f2380a7df3dfe390813a61944b43bf00d Git commit c7662ea126c8e28546c1b22bb53b03fbecbb028b by ivan tkachenko. Committed on 26/04/2023 at 15:16. Pushed by ratijas into branch 'Plasma/5.27'. landingpage: Fix broken binding in "Most Used Pages" grid First rule of the fighting club: never bind to a list. You never know what the heck you're up against. On the other hand, assigning FormData.buddyFor in a procedural way in the Repeater's hook is robust, and there's nothing that could go wrong. (cherry picked from commit 3bc36d5f2380a7df3dfe390813a61944b43bf00d) M +8 -1 kcms/landingpage/package/contents/ui/main.qml https://invent.kde.org/plasma/plasma-desktop/commit/c7662ea126c8e28546c1b22bb53b03fbecbb028b The issue has been resolved with this week's update. Updated system data: Operating System: KDE neon 5.27 KDE Plasma Version: 5.27.4 KDE Frameworks Version: 5.105.0 Qt Version: 5.15.9 Kernel Version: 5.19.0-41-generic (64-bit) Graphics Platform: X11 Processors: 8 × Intel® Xeon® CPU W3520 @ 2.67GHz Memory: 7.7 GiB of RAM Graphics Processor: GeForce GT 610/PCIe/SSE2 Manufacturer: Apple Inc. Product Name: MacPro4,1 System Version: 0.0 Armando, it sounds like your activity database got recreated, which therefore stopped triggering the bug. ...Because the fix was just merged today and can't possibly be on your machine yet. :) A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2868 Git commit a72ca3acdfc3edb269cdadb979bd2c16bde846b6 by ivan tkachenko. Committed on 26/04/2023 at 19:53. Pushed by ratijas into branch 'master'. applets/digital-clock: Fix broken binding in the list of calendar plugins First rule of the fighting club: never bind to a list. You never know what the heck you're up against. On the other hand, assigning FormData.buddyFor in a procedural way in the Repeater's hook is robust, and there's nothing that could go wrong. See also: https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1490 M +13 -1 applets/digital-clock/package/contents/ui/configCalendar.qml https://invent.kde.org/plasma/plasma-workspace/commit/a72ca3acdfc3edb269cdadb979bd2c16bde846b6 Git commit 28e6cab939007c54be4ea2b33b4ed7f4aa57bfa8 by ivan tkachenko. Committed on 26/04/2023 at 20:50. Pushed by ratijas into branch 'Plasma/5.27'. applets/digital-clock: Fix broken binding in the list of calendar plugins First rule of the fighting club: never bind to a list. You never know what the heck you're up against. On the other hand, assigning FormData.buddyFor in a procedural way in the Repeater's hook is robust, and there's nothing that could go wrong. See also: https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1490 (cherry picked from commit a72ca3acdfc3edb269cdadb979bd2c16bde846b6) M +12 -1 applets/digital-clock/package/contents/ui/configCalendar.qml https://invent.kde.org/plasma/plasma-workspace/commit/28e6cab939007c54be4ea2b33b4ed7f4aa57bfa8 A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1044 Armando, please don't mark bug reports as resolved when they are being actively worked on by KDE developers but haven't actually been fixed yet. Git commit b8a53cef1664bcef85c04db4e647024982a5140c by ivan tkachenko. Committed on 07/06/2023 at 15:37. Pushed by ratijas into branch 'master'. FormLayoutAttached: Fix checks in setter of buddyFor property, add tests Previous check didn't allow setting buddy for more than once (except for marginal case of setting deeper and deeper children, which isn't well supported by positioning code anyway). Not a highly needed feature, but it better be working properly. Also the code did not perform any checks that old m_buddyFor was non-null pointer, so the whole thing only worked because internally QQuickItem::isAncestorOf does not use any of the properties of `this` object, and only does checked parent() calls on its argument and compares results as raw pointers. Neither did it reset back to default (attachee) object if/when buddy is dynamically destroyed, so now there are reconnects in setter, and corresponding tests with a signal spy, Repeater and Component::createObject(). Test plan: https://invent.kde.org/frameworks/kirigami/-/snippets/2625 M +235 -2 autotests/tst_formlayout.qml M +37 -3 src/formlayoutattached.cpp M +7 -1 src/formlayoutattached.h https://invent.kde.org/frameworks/kirigami/-/commit/b8a53cef1664bcef85c04db4e647024982a5140c |