Bug 479258 - kwin_wayland occasionally hits `assert!(__hi < __lo)` in `std::clamp()` from KWin::Window::constrainClientSize()
Summary: kwin_wayland occasionally hits `assert!(__hi < __lo)` in `std::clamp()` from ...
Status: RESOLVED DUPLICATE of bug 478269
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: 5.27.10
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-01 15:39 UTC by Janne Grunau
Modified: 2024-01-01 15:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
drm_info output with kwin_wayland running (6.53 KB, text/plain)
2024-01-01 15:39 UTC, Janne Grunau
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janne Grunau 2024-01-01 15:39:26 UTC
Created attachment 164596 [details]
drm_info output with kwin_wayland running

SUMMARY
kwin_wayland occasionally crashes during powering the display on after DPMS hitting `assert!(__hi < __lo)` in `std::clamp()`. This seems to be an regression after updating to kwin-wayland-5.27.10-1.fc39 from kwin-wayland-5.27.9-3.fc39.

This issues seems to be triggered by the firmware of Apple's display controller. It generates a hotplug / unplug event a few seconds (~3 seconds) after the initial modeset succeeds after wakeup.

> 13:37:46 kernel: apple-dcp 38bc00000.dcp: set_digital_out_mode(color:85 timing:39) "3440x1440": 60 319750 3440 3488 3520 3600 1440 1443 1453 1481 0x40 0x0
> 13:37:46 kernel: apple-dcp 38bc00000.dcp: set_digital_out_mode() color mode depth:10 format:0 colorimetry:9 eotf:0 range:0
> 13:37:46 kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: nifiedPipeline.cpp:7462: set_digital_out_mode: Modeset requested for colorID: 85, timingID: 39
> 13:37:47 kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: UPTSQManager.cpp:105: IOMFB: switch to normal mode succeeded
> 13:37:47 kernel: apple-dcp 38bc00000.dcp: set_digital_out_mode finished:8229

modeset succeded

> 13:37:50 kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:146: IOMFB: IOAVVideoInterface terminated
> 13:37:50 kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: oInterfaceIOAV.cpp:1094: void VideoInterfaceIOAV::unplug_gated(IOAVVideoInterface *): display HPD removed
> 13:37:50 kernel: apple-dcp 38bc00000.dcp: cb_hotplug() connected:0, valid_mode:1
> 13:37:50 kernel: apple-dcp 38bc00000.dcp: dcp_hotplug() connected:0 valid_mode:0 nr_modes:29

unplug event

> 13:37:50 kwin_wayland_wrapper[1113221]: /usr/include/c++/13/bits/stl_algo.h:3669: constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = double]: Assertion '!(__hi < __lo)' failed.

Backtrace below:
> Core was generated by `/usr/bin/kwin_wayland --wayland-fd 7 --socket wayland-0 --xwayland-fd 8 --xwayl'.
> Program terminated with signal SIGABRT, Aborted.
> #0  __pthread_kill_implementation (threadid=281472158524768, signo=signo@entry=6, no_tid=no_tid@entry=0)
>     at pthread_kill.c:44
> Downloading source file /usr/src/debug/glibc-2.38-14.fc39.aarch64/nptl/pthread_kill.c
> 44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;                                 
> [Current thread is 1 (Thread 0xffff5805e560 (LWP 180747))]
> Missing separate debuginfos, use: dnf debuginfo-install kwin-wayland-5.27.10-1.fc39.aarch64
> (gdb) bt
> #0  __pthread_kill_implementation (threadid=281472158524768, signo=signo@entry=6, no_tid=no_tid@entry=0)
>     at pthread_kill.c:44
> #1  0x0000ffff553022f8 [PAC] in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
> #2  0x0000ffff552b5800 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
> #3  0x0000ffff552a0288 [PAC] in __GI_abort () at abort.c:79
> #4  0x0000ffff555d2db8 [PAC] in std::__glibcxx_assert_fail (
>     file=file@entry=0xffff5860f0b8 "/usr/include/c++/13/bits/stl_algo.h", line=line@entry=3669, 
>     function=function@entry=0xffff5860f060 "constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = double]", condition=condition@entry=0xffff5860f050 "!(__hi < __lo)")
>     at ../../../../../libstdc++-v3/src/c++11/assert_fail.cc:41
> #5  0x0000ffff58425910 [PAC] in std::clamp<double> (__val=<optimized out>, __lo=<optimized out>, __hi=<optimized out>)
>     at /usr/include/c++/13/bits/stl_algo.h:3667
> #6  std::clamp<double> (__hi=<optimized out>, __lo=<optimized out>, __val=<optimized out>)
>     at /usr/include/c++/13/bits/stl_algo.h:3667
> #7  KWin::Window::constrainClientSize (this=0xaaab9aa7a7b0, size=..., mode=<optimized out>)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/window.cpp:4278
> #8  0x0000ffff58427bc8 [PAC] in KWin::Window::constrainFrameSize (this=this@entry=0xaaab9aa7a7b0, size=..., 
>     mode=mode@entry=KWin::Window::SizeModeAny) at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/window.cpp:4290
> #9  0x0000ffff5842fa20 [PAC] in KWin::Window::checkWorkspacePosition (this=0xaaab9aa7a7b0, oldGeometry=..., 
>     oldDesktop=<optimized out>) at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/window.cpp:4236
> #10 0x0000ffff584474d0 [PAC] in KWin::Workspace::updateClientArea (this=this@entry=0xaaab99649f40)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/workspace.cpp:2441
> #11 0x0000ffff584483a4 [PAC] in KWin::Workspace::desktopResized (this=0xaaab99649f40)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/workspace.cpp:2224
> #12 0x0000ffff5843ef20 [PAC] in KWin::Workspace::updateOutputs (this=this@entry=0xaaab99649f40, outputOrder=...)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/workspace.cpp:1432
> #13 0x0000ffff5843ff98 [PAC] in KWin::Workspace::slotOutputBackendOutputsQueried (this=0xaaab99649f40)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/workspace.cpp:1327
> #14 0x0000ffff567e72bc [PAC] in QtPrivate::QSlotObjectBase::call (a=0xfffff4c68700, r=<optimized out>, 
>     this=0xaaab99a05160) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
> #15 doActivate<false> (sender=0xaaab995ddbd0, signal_index=3, argv=0xfffff4c68700) at kernel/qobject.cpp:3925
> #16 0x0000ffff58487fcc [PAC] in KWin::DrmBackend::updateOutputs (this=<optimized out>)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/backends/drm/drm_backend.cpp:333
> #17 0x0000ffff584828d0 [PAC] in KWin::DrmBackend::handleUdevEvent (this=0xaaab995ddbd0)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/backends/drm/drm_backend.cpp:259
> ...
> (gdb) f 7
> #7  KWin::Window::constrainClientSize (this=0xaaab9aa7a7b0, size=..., mode=<optimized out>)
>     at /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/window.cpp:4278
> Downloading source file /usr/src/debug/kwin-5.27.10-1.fc39.aarch64/src/window.cpp
> 4278        width = std::clamp(width, minimumSize.width(), maximumSize.width());                                        
> (gdb) info locals 
> width = 323
> height = 124
> minimumSize = <optimized out>
> maximumSize = <optimized out>

STEPS TO REPRODUCE
1. Login to Plasma (wayland) session
2. Wait for the display to shut off
3. Wake display and unlock session

OBSERVED RESULT
Empty desktop due kwin_wayland crash

EXPECTED RESULT
kwin_wayland doesn't crash

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11

ADDITIONAL INFORMATION
- Apple Silicon system with HDMI output running Fedora-Asahi-Remix (Fedora 39)
- Display: LG UltraWide 34WK95UP-W, 5120x2160 native resolution
- display connected via HDMI 2.0 limiting the max resolution to "3840x2160@60.00" but using the non-driver preferred mode "3440x1440@59.97"
Comment 1 Zamundaaa 2024-01-01 15:44:45 UTC

*** This bug has been marked as a duplicate of bug 478269 ***