Bug 452318 - kwin_wayland crashes on screen setup change
Summary: kwin_wayland crashes on screen setup change
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Unclassified
Component: multi-screen (show other bugs)
Version: git master
Platform: Other Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2022-04-06 08:58 UTC by Harald Sitter
Modified: 2022-05-17 11:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.24.5


Attachments
screenshot of display setup (233.90 KB, image/png)
2022-04-06 08:58 UTC, Harald Sitter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Sitter 2022-04-06 08:58:24 UTC
Created attachment 147994 [details]
screenshot of display setup

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
***

STEPS TO REPRODUCE
1. have 1 4k screen, 2 that are not
2. move 4k to center
3. rotate either side screen to portrait mode
4. boom

OBSERVED RESULT
Inside KWaylandServer::OutputDeviceV2InterfacePrivate::sendCurrentMode it can't find the resource.

Curiously this starts working when one first drops the refresh rate to 50hz -> apply -> rotate -> apply. 

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-38-generic (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600X 6-Core Processor
Memory: 31,3 GiB of RAM
Graphics Processor: AMD Radeon RX 5700 XT

ADDITIONAL INFORMATION

* thread #1, name = 'kwin_wayland', stop reason = signal SIGSEGV: invalid address (fault address: 0x10)
  * frame #0: 0x00007f0beda51f20 libKWaylandServer.so.5`KWaylandServer::OutputDeviceV2InterfacePrivate::sendCurrentMode(this=0x00005622aab31f60, outputResource=0x00005622abd2be40, mode=0x00005622aa9aa790) at outputdevice_v2_interface.cpp:304:22
    frame #1: 0x00007f0beda51869 libKWaylandServer.so.5`KWaylandServer::OutputDeviceV2Interface::setCurrentMode(this=0x00005622aa9aa890, mode=0x00005622aa9aa790) at outputdevice_v2_interface.cpp:185:27
    frame #2: 0x00007f0beda51a67 libKWaylandServer.so.5`KWaylandServer::OutputDeviceV2Interface::setCurrentMode(this=0x00005622aa9aa890, size=0x00007fff26527be0, refreshRate=60000) at outputdevice_v2_interface.cpp:201:19
    frame #3: 0x00007f0beebae5ae libkwin.so.5`KWin::WaylandOutputDevice::handleCurrentModeChanged(this=0x00005622aad6c7a0) at waylandoutputdevicev2.cpp:146:37
    frame #4: 0x00007f0bece6adfe libQt5Core.so.5`void doActivate<false>(QObject*, int, void**) at qobjectdefs_impl.h:398:57
    frame #5: 0x00007f0beea63777 libkwin.so.5`KWin::AbstractWaylandOutput::setTransformInternal(this=0x00005622aad6a6e0, transform=<unavailable>) at abstract_wayland_output.cpp:246:34
    frame #6: 0x00007f0be5d6925f KWinWaylandDrmBackend.so`KWin::DrmOutput::applyQueuedChanges(this=0x00005622aad6a6e0, config=0x00007fff26527e30) at drm_output.cpp:402:25
    frame #7: 0x00007f0be5d525b7 KWinWaylandDrmBackend.so`KWin::DrmBackend::applyOutputChanges(this=0x00005622aa9aafc0, config=0x00007fff26527e30) at drm_backend.cpp:671:35
    frame #8: 0x00007f0beeb1256b libkwin.so.5`KWin::Platform::requestOutputsChange(this=0x00005622aa9aafc0, config=0x00005622abd87b90) at platform.cpp:139:27
    frame #9: 0x00007f0bece6adfe libQt5Core.so.5`void doActivate<false>(QObject*, int, void**) at qobjectdefs_impl.h:398:57
    frame #10: 0x00007f0beda06040 libKWaylandServer.so.5`KWaylandServer::OutputManagementV2Interface::configurationChangeRequested(this=0x00005622aa9d58b0, _t1=0x00005622abd87b90) at moc_outputmanagement_v2_interface.cpp:136:26
    frame #11: 0x00007f0beda575d3 libKWaylandServer.so.5`KWaylandServer::OutputConfigurationV2InterfacePrivate::emitConfigurationChangeRequested(this=0x00005622abd8c850) const at outputconfiguration_v2_interface.cpp:183:58
    frame #12: 0x00007f0beda57172 libKWaylandServer.so.5`KWaylandServer::OutputConfigurationV2InterfacePrivate::kde_output_configuration_v2_apply(this=0x00005622abd8c850, resource=0x00005622abc86550) at outputconfiguration_v2_interface.cpp:128:37
    frame #13: 0x00007f0bedaecc6e libKWaylandServer.so.5`QtWaylandServer::kde_output_configuration_v2::handle_apply(client=0x00005622abc902f0, resource=0x00005622abd65450) at qwayland-server-kde-output-management-v2.cpp:572:125
    frame #14: 0x00007f0be9e8eff5 libffi.so.7`ffi_call_unix64 at unix64.S:101
    frame #15: 0x00007f0be9e8e40a libffi.so.7`ffi_call_int at ffi64.c:669:3
    frame #16: 0x00007f0beb58e8e8 libwayland-server.so.0`___lldb_unnamed_symbol82$$libwayland-server.so.0 + 360
    frame #17: 0x00007f0beb58ab72 libwayland-server.so.0`___lldb_unnamed_symbol27$$libwayland-server.so.0 + 562
    frame #18: 0x00007f0beb58c8da libwayland-server.so.0`wl_event_loop_dispatch + 202
    frame #19: 0x00007f0beda286d8 libKWaylandServer.so.5`KWaylandServer::Display::dispatchEvents(this=0x00005622aa9dae10) at display.cpp:114:31
    frame #20: 0x00007f0beda2d347 libKWaylandServer.so.5`QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWaylandServer::Display::*)()>::call(f=98 86 a2 ed 0b 7f 00 00 00 00 00 00 00 00 00 00, o=0x00005622aa9dae10, arg=0x00007fff26528810)(), KWaylandServer::Display*, void**) at qobjectdefs_impl.h:152:20
    frame #21: 0x00007f0beda2d0a7 libKWaylandServer.so.5`void QtPrivate::FunctionPointer<void (KWaylandServer::Display::*)()>::call<QtPrivate::List<>, void>(f=98 86 a2 ed 0b 7f 00 00 00 00 00 00 00 00 00 00, o=0x00005622aa9dae10, arg=0x00007fff26528810)(), KWaylandServer::Display*, void**) at qobjectdefs_impl.h:185:95
    frame #22: 0x00007f0beda2c3eb libKWaylandServer.so.5`QtPrivate::QSlotObject<void (KWaylandServer::Display::*)(), QtPrivate::List<>, void>::impl(which=1, this_=0x00005622ab0e5430, r=0x00005622aa9dae10, a=0x00007fff26528810, ret=0x0000000000000000) at qobjectdefs_impl.h:418:49
    frame #23: 0x00007f0bece6adfe libQt5Core.so.5`void doActivate<false>(QObject*, int, void**) at qobjectdefs_impl.h:398:57
    frame #24: 0x00007f0bece6ee83 libQt5Core.so.5`QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type, QSocketNotifier::QPrivateSignal) at moc_qsocketnotifier.cpp:178:26
    frame #25: 0x00007f0bece6f623 libQt5Core.so.5`QSocketNotifier::event(QEvent*) at qsocketnotifier.cpp:302:23
    frame #26: 0x00007f0bec2bcdc3 libQt5Widgets.so.5`QApplicationPrivate::notify_helper(QObject*, QEvent*) at qapplication.cpp:3637:31
    frame #27: 0x00007f0bec2c5bd8 libQt5Widgets.so.5`QApplication::notify(QObject*, QEvent*) at qapplication.cpp:3161:39
    frame #28: 0x00007f0bece33d7a libQt5Core.so.5`QCoreApplication::notifyInternal2(QObject*, QEvent*) at qcoreapplication.cpp:1064:24
    frame #29: 0x00007f0bece8b86b libQt5Core.so.5`QEventDispatcherUNIXPrivate::activateSocketNotifiers() at qeventdispatcher_unix.cpp:304:36
    frame #30: 0x00007f0bece8bccb libQt5Core.so.5`QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at qeventdispatcher_unix.cpp:511:50
    frame #31: 0x00005622a9c10041 kwin_wayland`___lldb_unnamed_symbol4145$$kwin_wayland + 17
    frame #32: 0x00007f0bece3287b libQt5Core.so.5`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) at qeventloop.cpp:232:22
    frame #33: 0x00007f0bece3aa24 libQt5Core.so.5`QCoreApplication::exec() at qcoreapplication.cpp:1375:36
    frame #34: 0x00005622a9aecd6d kwin_wayland`___lldb_unnamed_symbol130$$kwin_wayland + 8301
    frame #35: 0x00007f0bebb6b0b3 libc.so.6`__libc_start_main + 243
    frame #36: 0x00005622a9aee9ee kwin_wayland`___lldb_unnamed_symbol147$$kwin_wayland + 46
Comment 1 David Edmundson 2022-04-06 09:06:25 UTC
OutputDeviceModeV2InterfacePrivate::findResource can return a nullptr, guarding is trivial, but it implies that someone is calling setCurrentMode before setModes which should be fixed at the root.
Comment 2 David Edmundson 2022-04-06 09:40:32 UTC
Edit: It doesn't imply that. We guard that already.
It implies we have a unbound mode for a bound output.

Can you try patching libkscreen:

WaylandOutputDevice::~WaylandOutputDevice()
{
    qDeleteAll(m_modes);
    kde_output_device_v2_destroy(object());
}

and swap these two lines so we tear down the device first.
Comment 3 Harald Sitter 2022-04-06 10:48:35 UTC
Alas, makes no difference.
Comment 4 Vlad Zahorodnii 2022-04-08 09:39:58 UTC
Git commit 33df55c5a35fff6dbea59c2143f68eb38eca7f57 by Vlad Zahorodnii.
Committed on 08/04/2022 at 08:32.
Pushed by vladz into branch 'master'.

Add Q_ASSERT in OutputDeviceV2Interface::setCurrentMode()

M  +1    -0    src/server/outputdevice_v2_interface.cpp

https://invent.kde.org/plasma/kwayland-server/commit/33df55c5a35fff6dbea59c2143f68eb38eca7f57
Comment 5 Vlad Zahorodnii 2022-04-08 16:40:21 UTC
Git commit b40c4e3f4108b9a0be9b4f5d437e72f7c2aa3fea by Vlad Zahorodnii.
Committed on 08/04/2022 at 12:56.
Pushed by vladz into branch 'master'.

Simplify code that announces available modes and current mode

If no mode has the current flag set, the first mode object will be
announced twice.

There's also no benefit from sending the current mode as last. If the
current mode changes, the compositor will send the current_mode event,
not the mode event.

M  +11   -24   src/server/outputdevice_v2_interface.cpp

https://invent.kde.org/plasma/kwayland-server/commit/b40c4e3f4108b9a0be9b4f5d437e72f7c2aa3fea
Comment 6 Vlad Zahorodnii 2022-04-08 16:40:55 UTC
Git commit 40364d2ee670a5a74318ef96c643762293ca95f0 by Vlad Zahorodnii.
Committed on 08/04/2022 at 16:40.
Pushed by vladz into branch 'Plasma/5.24'.

Simplify code that announces available modes and current mode

If no mode has the current flag set, the first mode object will be
announced twice.

There's also no benefit from sending the current mode as last. If the
current mode changes, the compositor will send the current_mode event,
not the mode event.


(cherry picked from commit b40c4e3f4108b9a0be9b4f5d437e72f7c2aa3fea)

M  +11   -24   src/server/outputdevice_v2_interface.cpp

https://invent.kde.org/plasma/kwayland-server/commit/40364d2ee670a5a74318ef96c643762293ca95f0
Comment 7 Bug Janitor Service 2022-05-17 11:53:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwayland-server/-/merge_requests/365
Comment 8 Bug Janitor Service 2022-05-17 11:53:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwayland-server/-/merge_requests/367