Bug 438682 - Setting App to Use Material Style Results in Segmentation Fault
Summary: Setting App to Use Material Style Results in Segmentation Fault
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 5.83.0
Platform: Neon Linux
: NOR crash
Target Milestone: Not decided
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-15 14:55 UTC by Javier O. Cordero Pérez (Cuperino)
Modified: 2021-06-17 12:56 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Javier O. Cordero Pérez (Cuperino) 2021-06-15 14:55:08 UTC
SUMMARY
Setting a Kirigami program to use the Material style from a qtquickcontrols2.conf file results in a segmentation fault, likely related to a cyclic dependency on Kirigami's Units.qml.

STEPS TO REPRODUCE
1. Use KDE Frameworks 5.83.0
2. Create a basic Kirigami app; the template from KAppTemplate does the job.
3. Create a file named "qtquickcontrols2.conf" under "./src ".
4. Add the following contents to qtquickcontrols2.conf:

[Controls]
Style=Material

5. Load the file on the app as a resource, like so:

<RCC>
    <qresource prefix="/">
        <file alias="main.qml">contents/ui/main.qml</file>
        <file>qtquickcontrols2.conf</file>
    </qresource>
</RCC>


OBSERVED RESULT
When the Control's style is set to Material, Kirigami app execution results in a segmentation fault as follows:

Cyclic dependency detected between "file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/Units.qml" and "file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/Units.qml"
*** Program received signal SIGSEGV (Segmentation fault) ***

If you set the style to any other valid value, the program will run. If you replicate using a non-Kirigami template as your base, the program will run with any valid Style.


EXPECTED RESULT
One would expect Kirigami app to start with the Material theme, as they did in 5.82 and prior versions of KF5.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon 5.22 User Edition
KDE Plasma Version: 5.22
KDE Frameworks Version: 5.83
Qt Version: 5.15.3

ADDITIONAL INFORMATION
Graphics Platform: X11
Kernel Version: 5.8.0-55-lowlatency (64-bit)
Comment 1 David Redondo 2021-06-16 08:15:40 UTC
#0  0x00007ffff6311435 in QQmlNotifier::emitNotify (endpoint=0x555555ba09c0, a=a@entry=0x7fffff7ffa60) at qml/qqmlnotifier.cpp:81
#1  0x00007ffff62b3fcf in QQmlData::signalEmitted (object=0x555555ba01a0, index=4, a=0x7fffff7ffa60) at qml/qqmlengine.cpp:834
#2  0x00007ffff6a42e75 in doActivate<false> (sender=0x555555ba01a0, signal_index=4, argv=0x7fffff7ffa60) at kernel/qobject_p.h:110
#3  0x00007ffff6a3c6b7 in QMetaObject::activate (sender=<optimized out>, m=m@entry=0x7fffe8311700 <Kirigami::BasicThemeDefinition::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffff7ffa60)
    at kernel/qobject.cpp:3946
#4  0x00007fffe82f60e6 in Kirigami::BasicThemeDefinition::sync (this=<optimized out>, _t1=<optimized out>) at src/libkirigami/KF5Kirigami2_autogen/EWIEGA46WW/moc_basictheme_p.cpp:751
#5  0x00007fffe830484f in Kirigami::BasicTheme::event (this=0x555555d3d490, event=0x7fffff7ffd40) at /usr/include/c++/9/bits/unique_ptr.h:374
#6  0x00007ffff74e4dc3 in QApplicationPrivate::notify_helper (this=this@entry=0x555555574a30, receiver=receiver@entry=0x555555d3d490, e=e@entry=0x7fffff7ffd40) at kernel/qapplication.cpp:3632
#7  0x00007ffff74edbb8 in QApplication::notify (this=0x7fffffffd990, receiver=0x555555d3d490, e=0x7fffff7ffd40) at kernel/qapplication.cpp:3156
#8  0x00007ffff6a0c2ca in QCoreApplication::notifyInternal2 (receiver=0x555555d3d490, event=0x7fffff7ffd40) at ../../include/QtCore/5.15.3/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:325
#9  0x00007fffe82f9cd4 in Kirigami::PlatformThemeData::notifyWatchers<QColor> (newValue=..., oldValue=..., sender=0x555555d3d490, this=0x555555d3d750) at /usr/include/x86_64-linux-gnu/qt5/QtGui/qcolor.h:92
#10 Kirigami::PlatformThemeData::setColor (color=..., role=Kirigami::PlatformThemeData::TextColor, sender=0x555555d3d490, this=0x555555d3d750) at /home/david/kde/src/kirigami/src/libkirigami/platformtheme.cpp:157
#11 Kirigami::PlatformThemePrivate::setDataColor (value=..., color=Kirigami::PlatformThemeData::TextColor, theme=0x555555d3d490, this=<optimized out>) at /home/david/kde/src/kirigami/src/libkirigami/platformtheme.cpp:341
#12 Kirigami::PlatformTheme::setTextColor (this=this@entry=0x555555d3d490, color=...) at /home/david/kde/src/kirigami/src/libkirigami/platformtheme.cpp:577
#13 0x00007fffe830454a in Kirigami::BasicTheme::sync (this=0x555555d3d490) at /home/david/kde/src/kirigami/src/libkirigami/basictheme.cpp:243
#14 0x00007fffe83012c4 in Kirigami::PlatformTheme::qmlAttachedProperties (object=0x5555556b0c80) at /home/david/kde/src/kirigami/src/libkirigami/platformtheme.cpp:880
#15 0x00007ffff62b52e3 in QtQml::resolveAttachedProperties (pf=<optimized out>, data=0x5555556b0d50, object=object@entry=0x5555556b0c80, create=create@entry=true) at qml/qqmlengine.cpp:1617
#16 0x00007ffff62b561e in QtQml::qmlAttachedPropertiesObject (object=object@entry=0x5555556b0c80, func=<optimized out>, create=create@entry=true) at qml/qqmlengine.cpp:1682
#17 0x00007ffff6348adb in QV4::QQmlTypeWrapper::virtualGet (m=0x7fffe8607470, id=..., receiver=0x7fffe8607470, hasProperty=0x0) at ../../include/QtQml/5.15.3/QtQml/private/../../../../../src/qml/qml/qqmlengine.h:172
#18 0x00007ffff615c67c in QV4::Object::get (receiver=0x7fffe8607470, hasProperty=0x0, name=0x7fffe8607478, this=0x7fffe8607470) at ../../include/QtQml/5.15.3/QtQml/private/../../../../../src/qml/jsruntime/qv4string_p.h:167
#19 QV4::Lookup::getterFallback (l=<optimized out>, engine=0x555555710bc0, object=...) at jsruntime/qv4lookup.cpp:201
#20 0x00007fffe3a540c0 in ?? ()
#21 0x0000000000000000 in ?? ()

Also happens with  QT_QUICK_CONTROLS_STYLE="material"
Comment 2 Bug Janitor Service 2021-06-16 13:16:24 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/319
Comment 3 David Redondo 2021-06-17 12:56:52 UTC
Git commit 6f0833d55982d4502c8dba028f77d0596d8ed200 by David Redondo.
Committed on 16/06/2021 at 13:10.
Pushed by davidre into branch 'master'.

Only emit sync signal if we have finished construction

We cannot control what happens in slots connected to sync().
In particular our own Material style accesses the Theme attached
property in onSync. If we have not finished construction the engine
did not set the instance as the attachedObject and constructs a new
one. This eventually triggers syncToQml() again and so on, causing
a stack overflow.

M  +1    -1    src/libkirigami/basictheme.cpp

https://invent.kde.org/frameworks/kirigami/commit/6f0833d55982d4502c8dba028f77d0596d8ed200