Bug 471562 - Crash in KWin::DrmGammaRamp constructor
Summary: Crash in KWin::DrmGammaRamp constructor
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.6
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 475249 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-06-29 10:45 UTC by Cuchac
Modified: 2023-10-05 15:52 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.9
Sentry Crash Report:


Attachments
backtrace with debug symbols (14.61 KB, text/x-log)
2023-06-29 10:45 UTC, Cuchac
Details
system log (66.27 KB, text/x-log)
2023-08-14 11:43 UTC, Cuchac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cuchac 2023-06-29 10:45:42 UTC
Created attachment 159970 [details]
backtrace with debug symbols

SUMMARY
kwin_wayland crashes during resume from sleep. Backtrace with debug symbols included in attachment. 

Crash in KWin::DrmGammaRamp::DrmGammaRamp 

STEPS TO REPRODUCE
1. Resume from sleep

OBSERVED RESULT
kwin_wayland crashes

EXPECTED RESULT
nothing happens

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Kernel Version: 6.3.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × 12th Gen Intel® Core™ i7-1255U
Memory: 31,0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: Dell Inc.
Product Name: Latitude 5530

ADDITIONAL INFORMATION
Comment 1 David Edmundson 2023-06-30 08:31:26 UTC
#0  0x00007fce0e38ac03 in KWin::DrmGammaRamp::DrmGammaRamp(KWin::DrmCrtc*, std::shared_ptr<KWin::ColorTransformation> const&)
    (this=0x55a98ee1c140, crtc=0x0, transformation=std::shared_ptr<KWin::ColorTransformation> (use count 2, weak count 0) = {...}, this=<optimized out>, crtc=<optimized out>, transformation=<optimized out>)
    at /usr/src/debug/kwin/kwin-5.27.6/src/backends/drm/drm_pipeline.cpp:594
#1  0x00007fce0e38b299 in std::_Construct<KWin::DrmGammaRamp, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(KWin::DrmGammaRamp*, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__p=0x55a98ee1c140) at /usr/include/c++/13.1.1/bits/stl_construct.h:109
#2  std::allocator_traits<std::allocator<void> >::construct<KWin::DrmGammaRamp, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(std::allocator<void>&, KWin::DrmGammaRamp*, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__p=0x55a98ee1c140) at /usr/include/c++/13.1.1/bits/alloc_traits.h:660
#3  std::_Sp_counted_ptr_inplace<KWin::DrmGammaRamp, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(std::allocator<void>, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__a=..., this=0x55a98ee1c130) at /usr/include/c++/13.1.1/bits/shared_ptr_base.h:604
#4  std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<KWin::DrmGammaRamp, std::allocator<void>, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(KWin::DrmGammaRamp*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__a=..., __p=<optimized out>, this=<optimized out>)
    at /usr/include/c++/13.1.1/bits/shared_ptr_base.h:971
#5  std::__shared_ptr<KWin::DrmGammaRamp, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__tag=..., this=<optimized out>) at /usr/include/c++/13.1.1/bits/shared_ptr_base.h:1712
#6  std::shared_ptr<KWin::DrmGammaRamp>::shared_ptr<std::allocator<void>, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) (__tag=..., this=<optimized out>) at /usr/include/c++/13.1.1/bits/shared_ptr.h:464
#7  std::make_shared<KWin::DrmGammaRamp, KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&>(KWin::DrmCrtc*&, std::shared_ptr<KWin::ColorTransformation> const&) ()
    at /usr/include/c++/13.1.1/bits/shared_ptr.h:1010
#8  KWin::DrmPipeline::setGammaRamp(std::shared_ptr<KWin::ColorTransformation> const&) (transformation=std::shared_ptr<KWin::ColorTransformation> (use count 2, weak count 0) = {...}, this=0x55a98dc4ea90)
Comment 2 MScattolin 2023-08-09 14:19:08 UTC
I'm experiencing the same crash with the exact same backtrace. However there's an oddity on my setup that triggers this crash so I thought about adding it to this report just in case it's useful in any way.
I have only one display on a desktop computer, but it is connected through HDMI and DPI at same time from the same GPU. KScreen detects both connectors but I have the HDMI disabled. I have it this way because the UEFI settings on my motherboard refuse to work through the DP output, so this weird setup is not KDE related

It crashes when waking up from sleep if I have the HDMI cable connected but disabled on KScreen, it never happens if it's physically unplugged
Comment 3 Cuchac 2023-08-14 11:42:18 UTC
Hello,
I have "relatively simple and common" setup. Notebook screen turned off, USB-C DELL docking station and two DP monitors.

I believe this has something to do with all the screens being OFF - notebook screen still off and docking station not enabled yet. So system is without any monitor.

I'm attaching system log from crash time.
Comment 4 Cuchac 2023-08-14 11:43:03 UTC
Created attachment 160947 [details]
system log
Comment 5 Cuchac 2023-08-14 11:45:32 UTC
This is the only line form kwin_wayland from system log:

kwin_wayland[1224]: [13::32:22.354] unknown: failed to open drm device at ""
Comment 6 Radek Novacek 2023-09-07 16:19:23 UTC
Same thing happens to me (not 100% times, more like 25%) - laptop with internal screen off, external screen connected through USB-C <-> DP cable.
Comment 7 Radek Novacek 2023-09-07 16:22:03 UTC
Should have said `kwin-5.27.7-2.fc37.x86_64` on Fedora 37 running Wayland session. KDE from this COPR repo: https://copr.fedorainfracloud.org/coprs/zawertun/kde/
Comment 8 Cuchac 2023-09-12 12:30:00 UTC
Hello,
is there anything I can do to help resolve this issue? It happens every day to me. I have no problem to apply some patch and provide another core dump.
I can try to debug this and maybe fix some NULL pointer dereference, but that would probably not fix the core issue, and it will fail in another way.
Comment 9 Bug Janitor Service 2023-09-12 14:25:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4404
Comment 10 Bug Janitor Service 2023-09-12 14:28:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4405
Comment 11 Zamundaaa 2023-09-12 14:29:02 UTC
I can't reproduce the bug myself, but if you could test https://invent.kde.org/plasma/kwin/-/merge_requests/4405 to make sure it actually fixes the issue that would be great
Comment 12 Zamundaaa 2023-09-12 14:50:43 UTC
Git commit 57fae99f33aa5d092ebb82e9924fbd7fbb932fc7 by Xaver Hugl.
Committed on 12/09/2023 at 16:34.
Pushed by zamundaaa into branch 'master'.

backends/drm: check activePending instead of active for when applying a new gamma ramp is allowed

The crtc may not be set yet in some cases

M  +2    -2    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/57fae99f33aa5d092ebb82e9924fbd7fbb932fc7
Comment 13 Zamundaaa 2023-09-12 15:16:38 UTC
Git commit f099b206b6d8cffee1b410a51e540d3750c4a0af by Xaver Hugl.
Committed on 12/09/2023 at 17:00.
Pushed by zamundaaa into branch 'Plasma/5.27'.

backends/drm: check activePending instead of active for when applying a new gamma ramp is allowed

The crtc may not be set yet in some cases
(cherry picked from commit 57fae99f33aa5d092ebb82e9924fbd7fbb932fc7)

M  +2    -2    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/f099b206b6d8cffee1b410a51e540d3750c4a0af
Comment 14 Cuchac 2023-09-14 10:06:34 UTC
Hello,
thank you for support!

I've applied https://invent.kde.org/plasma/kwin/-/commit/f099b206b6d8cffee1b410a51e540d3750c4a0af.diff and will let you know the result.
Comment 15 Cuchac 2023-09-15 11:02:17 UTC
So far so good!
Tried several times connect/disconnect, different scenarios and still holding after 24 hours
Comment 16 Radek Novacek 2023-09-21 18:23:32 UTC
I have applied that patch and it's also solid for me. No more crashes observed. Thanks everyone!
Comment 17 Zamundaaa 2023-10-05 15:52:09 UTC
*** Bug 475249 has been marked as a duplicate of this bug. ***