Skip to content

Fix DialogPrivate::syncToMainItemSize Qt6 qBound assert

Dāvis Mosāns requested to merge davism/plasma-framework:qbound into master

Qt6 added assert for qBound when min > max. See https://codereview.qt-project.org/c/qt/qtbase/+/383882

We calculate min/max separately and thus it can get out of sync with min being larger than max.

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f286bea0953 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f286be51ea8 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f286ec3576e in KCrash::defaultCrashHandler (sig=6) at /usr/src/debug/kcrash-git/kcrash/src/kcrash.cpp:597
#4  <signal handler called>
#5  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#6  0x00007f286bea0953 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#7  0x00007f286be51ea8 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#8  0x00007f286be3b53d in __GI_abort () at abort.c:79
#9  0x00007f286c4a41c7 in qAbort () at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qglobal.cpp:3369
#10 0x00007f286c4a449a in qt_message_fatal (message=<synthetic pointer>..., context=...) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qlogging.cpp:1916
#11 QMessageLogger::fatal (this=this@entry=0x7ffee50835e8, msg=msg@entry=0x7f286c7bad30 "ASSERT: \"%s\" in file %s, line %d") at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qlogging.cpp:850
#12 0x00007f286c4a44f8 in qt_assert (assertion=assertion@entry=0x7f286f11428b "!(max < min)", file=file@entry=0x7f286f113e78 "/usr/include/qt6/QtCore/qglobal.h", line=line@entry=1032) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qglobal.cpp:3276
#13 0x00007f286f0da8f8 in qBound<int> (max=<optimized out>, val=<optimized out>, min=<optimized out>) at /usr/include/qt6/QtCore/qglobal.h:1032
#14 0x00007f286f0daac8 in qBound<int> (max=<optimized out>, val=<optimized out>, min=<optimized out>) at /usr/src/debug/plasma-framework-git/plasma-framework/src/plasmaquick/dialog.cpp:656
#15 PlasmaQuick::DialogPrivate::syncToMainItemSize (this=0x55a223194ff0) at /usr/src/debug/plasma-framework-git/plasma-framework/src/plasmaquick/dialog.cpp:692
#16 0x00007f286f0ef48f in PlasmaQuick::DialogPrivate::updateVisibility (this=0x55a223194ff0, visible=<optimized out>) at /usr/src/debug/plasma-framework-git/plasma-framework/src/plasmaquick/dialog.cpp:305
#17 0x00007f286f0f14da in PlasmaQuick::Dialog::event (this=0x55a223198400, event=0x7ffee50839b0) at /usr/src/debug/plasma-framework-git/plasma-framework/src/plasmaquick/dialog.cpp:1462
#18 0x00007f286db759bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55a223198400, e=0x7ffee50839b0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/widgets/kernel/qapplication.cpp:3315
#19 0x00007f286c52a258 in QCoreApplication::notifyInternal2 (receiver=0x55a223198400, event=0x7ffee50839b0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qcoreapplication.cpp:1026
#20 0x00007f286cbe6f8c in QWindowPrivate::setVisible (this=0x55a222cbfdb0, visible=<optimized out>) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/gui/kernel/qwindow.cpp:369
#21 0x00007f286d445068 in QQmlPropertyData::writeProperty (this=<optimized out>, target=<optimized out>, value=<optimized out>, flags=...) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlpropertydata_p.h:338
#22 0x00007f286d4576af in GenericBinding<1>::doStore<bool> (flags=..., pd=<optimized out>, value=<optimized out>, this=<optimized out>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlbinding.cpp:357
#23 GenericBinding<1>::write (this=0x55a22308cc30, result=..., isUndefined=<optimized out>, flags=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlbinding.cpp:320
#24 0x00007f286d454daa in QQmlNonbindingBinding::doUpdate (this=0x55a22308cc30, watcher=..., flags=..., scope=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlbinding.cpp:249
#25 0x00007f286d454881 in QQmlBinding::update (this=0x55a22308cc30, flags=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlbinding.cpp:163
#26 0x00007f286d4c6116 in QQmlNotifier::emitNotify (endpoint=<optimized out>, a=0x7ffee50855f0) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlnotifier.cpp:70
#27 0x00007f286c580170 in doActivate<false> (sender=0x55a2226a6910, signal_index=34, argv=0x7ffee50855f0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qobject.cpp:3871
#28 0x00007f286f0de8d3 in PlasmaQuick::AppletQuickItem::expandedChanged (this=<optimized out>, _t1=<optimized out>) at /usr/src/debug/plasma-framework-git/build/src/plasmaquick/KF6PlasmaQuick_autogen/include/moc_appletquickitem.cpp:501
#29 0x00007f286f0e72ff in PlasmaQuick::AppletQuickItem::qt_metacall (this=this@entry=0x55a2226a6910, _c=_c@entry=QMetaObject::WriteProperty, _id=7, _a=_a@entry=0x7ffee50856a0) at /usr/src/debug/plasma-framework-git/build/src/plasmaquick/KF6PlasmaQuick_autogen/include/moc_appletquickitem.cpp:477
#30 0x00007f285ffc0cb6 in AppletInterface::qt_metacall (this=0x55a2226a6910, _c=QMetaObject::WriteProperty, _id=<optimized out>, _a=0x7ffee50856a0) at /usr/src/debug/plasma-framework-git/build/src/scriptengines/qml/plasma_appletscript_declarative_autogen/include/moc_appletinterface.cpp:1231
#31 0x00007f286d4450c8 in QQmlPropertyData::doMetacall<(QMetaObject::Call)2> (this=<optimized out>, argv=0x7ffee50856a0, idx=<optimized out>, object=<optimized out>) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlpropertydata_p.h:322
#32 QQmlPropertyData::doMetacall<(QMetaObject::Call)2> (this=<optimized out>, argv=0x7ffee50856a0, idx=<optimized out>, object=<optimized out>) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlpropertydata_p.h:317
#33 QQmlPropertyData::writeProperty (this=<optimized out>, target=<optimized out>, value=<optimized out>, flags=...) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlpropertydata_p.h:340
#34 0x00007f286d4e02fa in QQmlPropertyPrivate::write (object=0x55a2226a6910, property=..., value=..., context=..., flags=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlproperty.cpp:1381
#35 0x00007f286d3c54e4 in QV4::QObjectWrapper::setProperty (engine=0x55a222bee4e0, object=0x55a2226a6910, property=0x55a222bd3760, value=...) at /usr/include/qt6/QtCore/qflags.h:73
#36 0x00007f286d3bc31f in QV4::QObjectWrapper::setQmlProperty (engine=0x55a222bee4e0, qmlContext=..., object=0x55a2226a6910, name=<optimized out>, revisionMode=QV4::QObjectWrapper::IgnoreRevision, value=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4qobjectwrapper.cpp:427
#37 0x00007f286d53f375 in QV4::QQmlTypeWrapper::virtualPut (m=<optimized out>, id=..., value=..., receiver=<optimized out>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmltypewrapper.cpp:306
#38 0x00007f286d3ab7fc in QV4::Object::put (receiver=<optimized out>, v=..., id=..., this=<optimized out>, this=<optimized out>, id=..., v=..., receiver=<optimized out>) at/usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4object_p.h:288
#39 QV4::Object::virtualResolveLookupSetter (object=0x7f283f3be538, engine=0x55a222bee4e0, lookup=0x55a223657d70, value=...) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4object.cpp:803
#40 0x00007f286d413957 in QV4::Moth::VME::interpret (frame=0x7ffee5085fd0, engine=0x55a222bee4e0, code=0x7f283c6055ed "\032\b\006\326\026\006\002") at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4vme_moth.cpp:317
#41 0x00007f286d421d9c in QV4::Moth::VME::exec (frame=<optimized out>, engine=<optimized out>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4vme_moth.cpp:542
#42 0x00007f286d38e2ca in QV4::Function::call (context=0x0, argc=-692510642, argv=0x7f283f3be500, thisObject=0x55a222bee4e0, this=0x7f283f3be500) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4function.cpp:62
#43 QV4::Function::call (this=this@entry=0x55a223120670, thisObject=thisObject@entry=0x7f283f3be4f8, argv=argv@entry=0x7f283f3be4f0, argc=argc@entry=1, context=context@entry=0x7f2866352c78) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4function.cpp:44
#44 0x00007f286d38e4db in operator() (argc=1, argv=0x7f283f3be4f0, thisObject=0x7f283f3be4f8, __closure=<synthetic pointer>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4function.cpp:31
#45 QV4::convertAndCall<QV4::Function::call(QObject*, void**, const QMetaType*, int, QV4::ExecutionContext*)::<lambda(const QV4::Value*, const QV4::Value*, int)> > (call=..., argc=1, types=0x7ffee5086258, a=0x7ffee5087d40, thisObject=0x55a2230af350, engine=<optimized out>) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4jscall_p.h:197
#46 QV4::Function::call (this=0x55a223120670, thisObject=0x55a2230af350, a=0x7ffee5087d40, types=0x7ffee5086258, argc=1, context=0x7f2866352c78) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/jsruntime/qv4function.cpp:28
#47 0x00007f286d4a837a in QQmlJavaScriptExpression::evaluate (this=<optimized out>, a=<optimized out>, types=<optimized out>, argc=<optimized out>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmljavascriptexpression.cpp:270
#48 0x00007f286d4596e3 in QQmlBoundSignalExpression::evaluate (this=this@entry=0x55a2230d43d0, a=a@entry=0x7ffee5087d40) at /usr/include/qt6/QtCore/qvarlengtharray.h:84
#49 0x00007f286d45e2ac in QQmlBoundSignal_callback (a=0x7ffee5087d40, e=0x55a2231ee110) at /usr/src/debug/qt6-declarative/build/include/QtQml/6.4.2/QtQml/private/../../../../../../qtdeclarative-everywhere-src-6.4.2/src/qml/qml/ftw/qqmlrefcount_p.h:62
#50 QQmlBoundSignal_callback (e=0x55a2231ee110, a=0x7ffee5087d40) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlboundsignal.cpp:293
#51 0x00007f286d4c6116 in QQmlNotifier::emitNotify (endpoint=<optimized out>, a=0x7ffee5087d40) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/qml/qml/qqmlnotifier.cpp:70
#52 0x00007f286c580170 in doActivate<false> (sender=0x55a2230af350, signal_index=48, argv=0x7ffee5087d40) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qobject.cpp:3871
#53 0x00007f286e3e9917 in QQuickMouseArea::clicked (this=this@entry=0x55a2230af350, _t1=<optimized out>, _t1@entry=0x55a2231ee558) at /usr/src/debug/qt6-declarative/build/src/quick/Quick_autogen/include/moc_qquickmousearea_p.cpp:797
#54 0x00007f286e3f0f89 in QQuickMouseArea::setPressed (this=this@entry=0x55a2230af350, button=<optimized out>, p=p@entry=false, source=Qt::MouseEventNotSynthesized) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/items/qquickmousearea.cpp:1226
#55 0x00007f286e3f1879 in QQuickMouseArea::mouseReleaseEvent (this=0x55a2230af350, event=0x7ffee5088870) at /usr/include/qt6/QtGui/qevent.h:108
#56 0x00007f286e3cf4cd in QQuickItem::event (this=0x55a2230af350, ev=0x7ffee5088870) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/items/qquickitem.cpp:8764
#57 0x00007f286db759bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55a2230af350, e=0x7ffee5088870) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/widgets/kernel/qapplication.cpp:3315
#58 0x00007f286c52a258 in QCoreApplication::notifyInternal2 (receiver=0x55a2230af350, event=0x7ffee5088870) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qcoreapplication.cpp:1026
#59 0x00007f286e52ad3f in QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem (this=this@entry=0x55a222fdc3b0, item=item@entry=0x55a2230af350, isGrabber=isGrabber@entry=true, pointerEvent=pointerEvent@entry=0x7ffee5088870, handlersOnly=handlersOnly@entry=false) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/util/qquickdeliveryagent.cpp:2111
#60 0x00007f286e52cb9a in QQuickDeliveryAgentPrivate::deliverUpdatedPoints (this=0x55a222fdc3b0, event=0x7ffee5088870) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/util/qquickdeliveryagent.cpp:1957
#61 0x00007f286e52e55c in QQuickDeliveryAgentPrivate::deliverPointerEvent (this=this@entry=0x55a222fdc3b0, event=event@entry=0x7ffee5088870) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/util/qquickdeliveryagent.cpp:1824
#62 0x00007f286e52ec8d in QQuickDeliveryAgentPrivate::handleMouseEvent (this=0x55a222fdc3b0, event=0x7ffee5088870) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/util/qquickdeliveryagent.cpp:1614
#63 0x00007f286e525e19 in QQuickDeliveryAgent::event (this=<optimized out>, ev=0x7ffee5088870) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/util/qquickdeliveryagent.cpp:687
#64 0x00007f286e46a6bc in QQuickWindow::event (this=<optimized out>, event=<optimized out>) at /usr/src/debug/qt6-declarative/qtdeclarative-everywhere-src-6.4.2/src/quick/items/qquickwindow.cpp:1475
#65 0x00007f286db759bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55a2231f8880, e=0x7ffee5088870) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/widgets/kernel/qapplication.cpp:3315
#66 0x00007f286c52a258 in QCoreApplication::notifyInternal2 (receiver=0x55a2231f8880, event=0x7ffee5088870) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qcoreapplication.cpp:1026
#67 0x000055a220b8b14e in PanelView::event (this=0x55a2231f8880, e=0x7ffee5088ac0) at /mnt/KDE/plasma-workspace/shell/panelview.cpp:1019
#68 0x00007f286db759bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55a2231f8880, e=0x7ffee5088ac0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/widgets/kernel/qapplication.cpp:3315
#69 0x00007f286c52a258 in QCoreApplication::notifyInternal2 (receiver=0x55a2231f8880, event=0x7ffee5088ac0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qcoreapplication.cpp:1026
#70 0x00007f286cb9a33c in QGuiApplicationPrivate::processMouseEvent (e=0x55a2237eac50) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/gui/kernel/qguiapplication.cpp:2249
#71 0x00007f286cbf7465 in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/gui/kernel/qwindowsysteminterface.cpp:1103
#72 0x00007f28678543e0 in xcbSourceDispatch (source=<optimized out>) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:57
#73 0x00007f286af4f82b in g_main_dispatch (context=0x7f2860005040) at ../glib/glib/gmain.c:3454
#74 g_main_context_dispatch (context=0x7f2860005040) at ../glib/glib/gmain.c:4172
#75 0x00007f286afa6cc9 in g_main_context_iterate.constprop.0 (context=0x7f2860005040, block=1, dispatch=1, self=<optimized out>) at ../glib/glib/gmain.c:4248
#76 0x00007f286af4e0e2 in g_main_context_iteration (context=0x7f2860005040, may_block=1) at ../glib/glib/gmain.c:4313
#77 0x00007f286c74d382 in QEventDispatcherGlib::processEvents (this=0x55a22267aa10, flags=...) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/kernel/qeventdispatcher_glib.cpp:393
#78 0x00007f286c535604 in QEventLoop::exec (this=0x7ffee5088f70, flags=...) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qflags.h:34
#79 0x00007f286c52ce7b in QCoreApplication::exec () at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/corelib/global/qflags.h:74
#80 0x00007f286cb954b2 in QGuiApplication::exec () at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/gui/kernel/qguiapplication.cpp:1859
#81 0x00007f286db676da in QApplication::exec () at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.4.2/src/widgets/kernel/qapplication.cpp:2595
#82 0x000055a220b645f9 in main (argc=<optimized out>, argv=<optimized out>) at /mnt/KDE/plasma-workspace/shell/main.cpp:235
(gdb) f 15
#15 PlasmaQuick::DialogPrivate::syncToMainItemSize (this=0x55a223194ff0) at /usr/src/debug/plasma-framework-git/plasma-framework/src/plasmaquick/dialog.cpp:692
    QSize min;
    QSize max(DIALOGSIZE_MAX, DIALOGSIZE_MAX);
    getSizeHints(min, max);
    s = QSize(qBound(min.width(), s.width(), max.width()), qBound(min.height(), s.height(), max.height()));
(gdb) p min
$7 = {
wd = 228,
ht = 155
}
(gdb) p s
$8 = {
wd = 444,
ht = 443
}
(gdb) p max
$9 = {
wd = 156,
ht = 41
}

Merge request reports