Bug 455477 - Crash in KScreen::Mode::id() on Wayland when setting resolution to 1280x720 when native resolution is 1920x1080
Summary: Crash in KScreen::Mode::id() on Wayland when setting resolution to 1280x720 w...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_kscreen (show other bugs)
Version: 5.25.0
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: kscreen-bugs-null@kde.org
URL:
Keywords: drkonqi
: 456274 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-06-17 12:03 UTC by simaduck
Modified: 2023-09-05 19:43 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.25.3


Attachments
New crash information added by DrKonqi (6.07 KB, text/plain)
2022-07-05 02:42 UTC, audun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description simaduck 2022-06-17 12:03:10 UTC
Application: systemsettings (5.25.0)

Qt Version: 5.15.4
Frameworks Version: 5.95.0
Operating System: Linux 5.18.3-zen1-1-zen x86_64
Windowing System: Wayland
Distribution: "Arch Linux"
DrKonqi: 5.25.0 [KCrashBackend]

-- Information about the crash:
Can't set 1280x720 (wayland).
Native resolution 1920x1080.

The crash can be reproduced every time.

-- Backtrace:
Application: Параметры системы (systemsettings), signal: Segmentation fault

[KCrash Handler]
#4  0x00007ff3262833c4 in KScreen::Mode::id() const () at /usr/lib/libKF5Screen.so.7
#5  0x00007ff32631f1db in  () at /usr/lib/qt/plugins/kcms/kcm_kscreen.so
#6  0x00007ff35fd9a268 in  () at /usr/lib/libQt5QmlModels.so.5
#7  0x00007ff35fd948b4 in  () at /usr/lib/libQt5QmlModels.so.5
#8  0x00007ff36263be43 in  () at /usr/lib/libQt5Qml.so.5
#9  0x00007ff362572ae0 in QV4::QObjectWrapper::setProperty(QV4::ExecutionEngine*, QObject*, QQmlPropertyData*, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5
#10 0x00007ff3625732a6 in QV4::QObjectWrapper::setQmlProperty(QV4::ExecutionEngine*, QQmlContextData*, QObject*, QV4::String*, QV4::QObjectWrapper::RevisionMode, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5
#11 0x00007ff362576337 in QV4::QObjectWrapper::virtualPut(QV4::Managed*, QV4::PropertyKey, QV4::Value const&, QV4::Value*) () at /usr/lib/libQt5Qml.so.5
#12 0x00007ff36254ec5c in QV4::Object::virtualResolveLookupSetter(QV4::Object*, QV4::ExecutionEngine*, QV4::Lookup*, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5
#13 0x00007ff36258dcbf in  () at /usr/lib/libQt5Qml.so.5
#14 0x00007ff362597d64 in  () at /usr/lib/libQt5Qml.so.5
#15 0x00007ff36253b7a6 in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*) () at /usr/lib/libQt5Qml.so.5
#16 0x00007ff36268fb0d in QQmlJavaScriptExpression::evaluate(QV4::CallData*, bool*) () at /usr/lib/libQt5Qml.so.5
#17 0x00007ff362652de1 in QQmlBoundSignalExpression::evaluate(void**) () at /usr/lib/libQt5Qml.so.5
#18 0x00007ff362653d5c in  () at /usr/lib/libQt5Qml.so.5
#19 0x00007ff36267656f in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**) () at /usr/lib/libQt5Qml.so.5
#20 0x00007ff3648bdd7d in  () at /usr/lib/libQt5Core.so.5
#21 0x00007ff35eca8853 in QQuickComboBox::activated(int) () at /usr/lib/libQt5QuickTemplates2.so.5
#22 0x00007ff35ec2a60a in  () at /usr/lib/libQt5QuickTemplates2.so.5
#23 0x00007ff3648be251 in  () at /usr/lib/libQt5Core.so.5
#24 0x00007ff35ec1ea5a in QQuickAbstractButtonPrivate::handleRelease(QPointF const&) () at /usr/lib/libQt5QuickTemplates2.so.5
#25 0x00007ff35ec39ab9 in QQuickControl::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/libQt5QuickTemplates2.so.5
#26 0x00007ff362c3c1c9 in QQuickItem::event(QEvent*) () at /usr/lib/libQt5Quick.so.5
#27 0x00007ff365578a7c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#28 0x00007ff36488db28 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#29 0x00007ff362c4cd93 in QQuickWindowPrivate::deliverMouseEvent(QQuickPointerMouseEvent*) () at /usr/lib/libQt5Quick.so.5
#30 0x00007ff362c4d7f2 in QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent*) () at /usr/lib/libQt5Quick.so.5
#31 0x00007ff364d55d15 in QWindow::event(QEvent*) () at /usr/lib/libQt5Gui.so.5
#32 0x00007ff365578a7c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#33 0x00007ff36488db28 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#34 0x00007ff363749cae in QQuickWidget::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/libQt5QuickWidgets.so.5
#35 0x00007ff3655af677 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#36 0x00007ff365578a7c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#37 0x00007ff36557e289 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#38 0x00007ff36488db28 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#39 0x00007ff36557c287 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /usr/lib/libQt5Widgets.so.5
#40 0x00007ff3655cd345 in  () at /usr/lib/libQt5Widgets.so.5
#41 0x00007ff3655cf0ee in  () at /usr/lib/libQt5Widgets.so.5
#42 0x00007ff365578a7c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#43 0x00007ff36488db28 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#44 0x00007ff364d3f02c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt5Gui.so.5
#45 0x00007ff364d28985 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Gui.so.5
#46 0x00007ff361f60fa5 in  () at /usr/lib/libQt5WaylandClient.so.5
#47 0x00007ff363118c6b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#48 0x00007ff36316f001 in  () at /usr/lib/libglib-2.0.so.0
#49 0x00007ff363116392 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#50 0x00007ff3648d827c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#51 0x00007ff3648862ec in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#52 0x00007ff364890dd9 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#53 0x000055e14990eb93 in  ()
#54 0x00007ff363e29290 in  () at /usr/lib/libc.so.6
#55 0x00007ff363e2934a in __libc_start_main () at /usr/lib/libc.so.6
#56 0x000055e14990f4b5 in  ()
[Inferior 1 (process 1990) detached]

The reporter indicates this bug may be a duplicate of or related to bug 419876.

Reported using DrKonqi
Comment 1 Yerrey Dev 2022-06-17 16:24:42 UTC
I believe the issue might be related to some modes having bizarre refresh rates on Wayland. Running kscreen-console, you can output the modes and on my system at least 2 of these modes have negative refresh rates:

         "31"    "1368x768@-1501773"   QSize(1368, 768)   -1.50177e+06
         "32"    "1280x720@-1075622"   QSize(1280, 720)   -1.07562e+06

Both of these crash KScreen on Wayland, on X11 none of the modes have negative refresh rates. I'm running this on a VM so I can't be sure if QEMU is reporting the screen modes wrong, or if the problem is in Wayland reading them wrong.
Comment 2 simaduck 2022-06-18 12:09:08 UTC
(In reply to Yerrey Dev from comment #1)
> I believe the issue might be related to some modes having bizarre refresh
> rates on Wayland. Running kscreen-console, you can output the modes and on
> my system at least 2 of these modes have negative refresh rates:
> 
>          "31"    "1368x768@-1501773"   QSize(1368, 768)   -1.50177e+06
>          "32"    "1280x720@-1075622"   QSize(1280, 720)   -1.07562e+06
> 
> Both of these crash KScreen on Wayland, on X11 none of the modes have
> negative refresh rates. I'm running this on a VM so I can't be sure if QEMU
> is reporting the screen modes wrong, or if the problem is in Wayland reading
> them wrong.
I run system not on VM.
kscreen-console:
	 "0"    "1920x1080@60"   QSize(1920, 1080)   60.008
	 "1"    "1280x1024@-2026142"   QSize(1280, 1024)   -2.02614e+06
	 "2"    "1280x800@-1396948"   QSize(1280, 800)   -1.39695e+06
	 "3"    "1600x900@2058702"   QSize(1600, 900)   2.0587e+06
	 "4"    "1368x768@-1501773"   QSize(1368, 768)   -1.50177e+06
	 "5"    "1280x720@-1075622"   QSize(1280, 720)   -1.07562e+06
1920x1080 - default
1600x900 - doing nothing
other resolutions - crashes
Comment 3 Yerrey Dev 2022-06-19 21:24:55 UTC
The actual KCM crash is caused by https://invent.kde.org/plasma/kscreen/-/blob/master/kcm/output_model.cpp#L396 comparison, where the reported refresh rate is compared with being larger than bestRefreshRate which is 0. When the reported refresh rate is negative, this comparison will never trigger and we'll fail at the Q_ASSERT following right after.

A MR to fix the KCM crash would be trivial, but I've yet to figure out the reason of the negative refresh rates. Possibly something to do with libxcvt which was added in https://invent.kde.org/plasma/kwin/-/merge_requests/2235 for Wayland.
Comment 4 Nate Graham 2022-06-21 16:12:09 UTC
Could be an upstream bug in that library.
Comment 5 Zane 2022-06-24 13:34:09 UTC
I've hit a similar issue when in Plasma 5.25 on NixOS. I don't get the crash, but I do get nonsensical refresh rates, and the mode doesn't actually change.

* 3546x2160 - 60Hz (original, good) <-- This is the only mode that the EDID reports
* 2560x1600 - 728501Hz
* 1920x1200 - 1293352Hz

Here's the distro bug report, I can make a new one here if that'd be better:
https://github.com/NixOS/nixpkgs/issues/178393
Comment 6 Yerrey Dev 2022-06-26 19:58:33 UTC
(In reply to Zane from comment #5)
> I've hit a similar issue when in Plasma 5.25 on NixOS. I don't get the
> crash, but I do get nonsensical refresh rates, and the mode doesn't actually
> change.
> 
> * 3546x2160 - 60Hz (original, good) <-- This is the only mode that the EDID
> reports
> * 2560x1600 - 728501Hz
> * 1920x1200 - 1293352Hz
> 
> Here's the distro bug report, I can make a new one here if that'd be better:
> https://github.com/NixOS/nixpkgs/issues/178393

That is the same bug, the reason it doesn't crash is because the refresh rate is positive, not negative. It appears that none of the "common modes" added in https://invent.kde.org/plasma/kwin/-/merge_requests/2235 MR work on Wayland, and show up as bizarre high or bizarre negative refresh rates. Don't know if we can ping the original contributor to see if they know better whether it is upstream bug or not.
Comment 7 Zane 2022-06-29 14:57:42 UTC
(In reply to Yerrey Dev from comment #6)
> (In reply to Zane from comment #5)
> > I've hit a similar issue when in Plasma 5.25 on NixOS. I don't get the
> > crash, but I do get nonsensical refresh rates, and the mode doesn't actually
> > change.
> > 
> > * 3546x2160 - 60Hz (original, good) <-- This is the only mode that the EDID
> > reports
> > * 2560x1600 - 728501Hz
> > * 1920x1200 - 1293352Hz
> > 
> > Here's the distro bug report, I can make a new one here if that'd be better:
> > https://github.com/NixOS/nixpkgs/issues/178393
> 
> That is the same bug, the reason it doesn't crash is because the refresh
> rate is positive, not negative. It appears that none of the "common modes"
> added in https://invent.kde.org/plasma/kwin/-/merge_requests/2235 MR work on
> Wayland, and show up as bizarre high or bizarre negative refresh rates.
> Don't know if we can ping the original contributor to see if they know
> better whether it is upstream bug or not.

Probably the best way is for someone with a GitLab account (i.e. not myself) to create a kwin issue and ping them there.
Comment 8 Zamundaaa 2022-06-29 18:29:26 UTC
No need, I'm looking into the problem
Comment 9 Bug Janitor Service 2022-06-29 18:54:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2593
Comment 10 Zamundaaa 2022-06-30 00:34:43 UTC
Git commit 0c453739b1da4f0e0075fdaf2894e70b17271ef4 by Xaver Hugl.
Committed on 29/06/2022 at 18:53.
Pushed by zamundaaa into branch 'master'.

backends/drm: fix common mode generation

The unit for refresh rate was wrong, which caused insanely high as well
as negative refresh rates

M  +2    -2    src/backends/drm/drm_object_connector.cpp
M  +1    -1    src/backends/drm/drm_object_connector.h

https://invent.kde.org/plasma/kwin/commit/0c453739b1da4f0e0075fdaf2894e70b17271ef4
Comment 11 Zamundaaa 2022-06-30 01:51:04 UTC
Git commit d4d4a05444e18963359f3fa6fe482ed6a419aa19 by Xaver Hugl.
Committed on 30/06/2022 at 01:50.
Pushed by zamundaaa into branch 'Plasma/5.25'.

backends/drm: fix common mode generation

The unit for refresh rate was wrong, which caused insanely high as well
as negative refresh rates
(cherry picked from commit 0c453739b1da4f0e0075fdaf2894e70b17271ef4)

M  +2    -2    src/backends/drm/drm_object_connector.cpp
M  +1    -1    src/backends/drm/drm_object_connector.h

https://invent.kde.org/plasma/kwin/commit/d4d4a05444e18963359f3fa6fe482ed6a419aa19
Comment 12 Yerrey Dev 2022-07-03 20:07:58 UTC
*** Bug 456274 has been marked as a duplicate of this bug. ***
Comment 13 audun 2022-07-05 02:42:53 UTC
Created attachment 150401 [details]
New crash information added by DrKonqi

systemsettings (5.25.2) using Qt 5.15.5

Crashed when setting resolution to 1280x800 on virtual evdi screen.

Looks like the same bug as marked duplicate of, output of kscreen-console seems to confirm:

         "4"    "1920x1080@60"   QSize(1920, 1080)   60
         "40"    "1280x800@-1396948"   QSize(1280, 800)   -1.39695e+06

Other strange modes:
         "41"    "3200x1800@516402"   QSize(3200, 1800)   516402
         "42"    "2880x1620@638536"   QSize(2880, 1620)   638536
         "43"    "1600x900@2058702"   QSize(1600, 900)   2.0587e+06
         "44"    "1368x768@-1501773"   QSize(1368, 768)   -1.50177e+06

-- Backtrace (Reduced):
#4  0x00007f1b5993b3c4 in KScreen::Mode::id() const () at /usr/lib/libKF5Screen.so.7
[...]
#9  0x00007f1b7dbabbb0 in QV4::QObjectWrapper::setProperty(QV4::ExecutionEngine*, QObject*, QQmlPropertyData*, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5
#10 0x00007f1b7dbac376 in QV4::QObjectWrapper::setQmlProperty(QV4::ExecutionEngine*, QQmlContextData*, QObject*, QV4::String*, QV4::QObjectWrapper::RevisionMode, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5
#11 0x00007f1b7dbaf407 in QV4::QObjectWrapper::virtualPut(QV4::Managed*, QV4::PropertyKey, QV4::Value const&, QV4::Value*) () at /usr/lib/libQt5Qml.so.5
#12 0x00007f1b7db580e5 in QV4::Lookup::setterFallback(QV4::Lookup*, QV4::ExecutionEngine*, QV4::Value&, QV4::Value const&) () at /usr/lib/libQt5Qml.so.5