Bug 442677 - Crash in DrmPipeline::populateAtomicValues()
Summary: Crash in DrmPipeline::populateAtomicValues()
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.22.90
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: usability, wayland
: 442794 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-09-19 01:35 UTC by Samuel Reddy
Modified: 2021-09-23 14:18 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.23


Attachments
Backtrace (7.37 KB, text/vnd.kde.kcrash-report)
2021-09-19 01:35 UTC, Samuel Reddy
Details
SDDM Plasma Wayland Log File (44.65 KB, text/x-log)
2021-09-20 23:08 UTC, Samuel Reddy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Reddy 2021-09-19 01:35:33 UTC
Created attachment 141693 [details]
Backtrace

SUMMARY:
When I tried installing a sandboxed snap on my system, either from the terminal or from pamac, it sometimes causes KWin to crash.

STEPS TO REPRODUCE
1. Install a sandboxed snap(or multiple sandboxed snaps) on the system
2. KWin may crash while installing the sandboxed snap

OBSERVED RESULT:
KWin sometimes crashes while installing a sandboxed snap.


EXPECTED RESULT:
The snap installs and KWin does not crash

SOFTWARE/OS VERSIONS:
Linux/KDE Plasma: 
Operating System: Arch Linux
KDE Plasma Version: 5.22.90
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.14.5-zen2-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 8 × AMD Ryzen 5 3450U with Radeon Vega Mobile Gfx
Memory: 5.7 GiB of RAM
Graphics Processor: AMD Radeon™ Vega 8 Graphics

ADDITIONAL INFORMATION:
KWin also flickers everytime I install a sandboxed snap
Comment 1 Vlad Zahorodnii 2021-09-20 09:41:47 UTC
kwin crashes in

  bool needsModeset = std::any_of(m_allObjects.constBegin(), m_allObjects.constEnd(), [](auto obj){return obj->needsModeset();});

which makes absolutely no any sense (yay...)
Comment 2 Vlad Zahorodnii 2021-09-20 09:52:19 UTC
> KWin also flickers everytime I install a sandboxed snap
I can reproduce flickering, but not crash. Still, it's weird...
Comment 3 Vlad Zahorodnii 2021-09-20 10:06:03 UTC
It seems like when install or uninstall an app using snap, kwin receives udev change events for the drm card. It's strange not to say the least, but there shouldn't be flickering.
Comment 4 Zamundaaa 2021-09-20 12:34:57 UTC
Git commit e004f1b7fcfd479632078d1ad24df31884bce0d0 by Xaver Hugl.
Committed on 20/09/2021 at 12:28.
Pushed by zamundaaa into branch 'master'.

platforms/drm: fix buffer re-using

We don't always have explicit modifiers when we're using AMS

M  +2    -1    src/plugins/platforms/drm/drm_pipeline.cpp

https://invent.kde.org/plasma/kwin/commit/e004f1b7fcfd479632078d1ad24df31884bce0d0
Comment 5 Zamundaaa 2021-09-20 12:35:32 UTC
Git commit 266d41cd6eab455c3ae70066782b19f3cd1012a4 by Xaver Hugl.
Committed on 20/09/2021 at 12:35.
Pushed by zamundaaa into branch 'Plasma/5.23'.

platforms/drm: fix buffer re-using

We don't always have explicit modifiers when we're using AMS


(cherry picked from commit e004f1b7fcfd479632078d1ad24df31884bce0d0)

M  +2    -1    src/plugins/platforms/drm/drm_pipeline.cpp

https://invent.kde.org/plasma/kwin/commit/266d41cd6eab455c3ae70066782b19f3cd1012a4
Comment 6 Vlad Zahorodnii 2021-09-20 12:56:57 UTC
@Samuel can you please check your wayland logs after kwin crashes? Wayland session logs can be found at ~/.local/share/sddm/wayland-session.log. Before uploading the log, please make sure that it contains no sensitive information.
Comment 7 Vlad Zahorodnii 2021-09-20 12:59:33 UTC
My guess is that drmModeGetProperty() fails for some requested property so DrmObject nukes it, which later causes a crash.
Comment 8 Samuel Reddy 2021-09-20 23:08:34 UTC
Created attachment 141751 [details]
SDDM Plasma Wayland Log File
Comment 9 Samuel Reddy 2021-09-20 23:09:09 UTC
I have attached the sddm wayland log file
Comment 10 Zamundaaa 2021-09-21 07:44:22 UTC
> kwin_wayland_drm: Atomic commit failed! This should never happen! Device or resource busy
It looks like KWin tries to find a fitting output configuration, fails because the events happen in the middle of a frame and then there's nullptr Pipelines that might get used... should be fixed by https://invent.kde.org/plasma/kwin/-/merge_requests/1435, although I should add some more checks so that it reverts to the previous configuration in the case of failure, instead of crashing. The function should never fail but it can't hurt to make sure.

In the backtrace the DrmPipeline is not nullptr though... Not sure what's going on with that tbh.
Comment 11 Zamundaaa 2021-09-21 12:19:29 UTC
Git commit 6d79d855be0db6d4a102072e8cbc0dd593f2de92 by Xaver Hugl.
Committed on 21/09/2021 at 12:18.
Pushed by zamundaaa into branch 'master'.

platforms/drm: waitIdle before updating outputs

KMS can only ever have one frame pending at the moment. If we
update the outputs while a pageflip is still pending on any output
the atomic commit will fail with EBUSY, which both invalidates
the testing for output configuration and makes applying the wanted
configuration fail.

This can be removed again once KMS gains the ability to do mailbox
presentation; that will likely still take a while though.

M  +1    -0    src/plugins/platforms/drm/drm_gpu.cpp

https://invent.kde.org/plasma/kwin/commit/6d79d855be0db6d4a102072e8cbc0dd593f2de92
Comment 12 Zamundaaa 2021-09-21 12:19:50 UTC
Git commit acebd1abeb39a95dc5d9c544fa72241451419235 by Xaver Hugl.
Committed on 21/09/2021 at 12:19.
Pushed by zamundaaa into branch 'Plasma/5.23'.

platforms/drm: waitIdle before updating outputs

KMS can only ever have one frame pending at the moment. If we
update the outputs while a pageflip is still pending on any output
the atomic commit will fail with EBUSY, which both invalidates
the testing for output configuration and makes applying the wanted
configuration fail.

This can be removed again once KMS gains the ability to do mailbox
presentation; that will likely still take a while though.


(cherry picked from commit 6d79d855be0db6d4a102072e8cbc0dd593f2de92)

M  +1    -0    src/plugins/platforms/drm/drm_gpu.cpp

https://invent.kde.org/plasma/kwin/commit/acebd1abeb39a95dc5d9c544fa72241451419235
Comment 13 Nate Graham 2021-09-23 14:18:01 UTC
*** Bug 442794 has been marked as a duplicate of this bug. ***