Bug 468430 - Plasmashell X11 crashes in DesktopView::screenToFollow() when adding or removing a screen from a multimonitor setup
Summary: Plasmashell X11 crashes in DesktopView::screenToFollow() when adding or remov...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: generic-multiscreen (show other bugs)
Version: 5.27.4
Platform: Arch Linux Linux
: HI crash
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
: 466095 467756 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-04-12 18:14 UTC by yurapostates
Modified: 2023-04-22 05:14 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.5


Attachments
bt full attachment (13.77 KB, text/plain)
2023-04-12 18:14 UTC, yurapostates
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yurapostates 2023-04-12 18:14:24 UTC
Created attachment 158044 [details]
bt full attachment

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 multiple monitors
2. Switch off/remove the cable from one of the monitors

OBSERVED RESULT
plasmashell crashes. However the apps survive and plasmashell is automatically restarted shortly after

EXPECTED RESULT
No crash

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Graphics Platform: X11
(i have 2 GPUs, one is used exclusively for VM passthroughs)
Comment 1 Nate Graham 2023-04-13 19:20:11 UTC
What kind of cable is the monitor connected with?

Pasting the relevant part of the backtrace inline for searchability:


#5  QWeakPointer<QObject>::internalData() const (this=0x58) at /usr/include/qt/QtCore/qsharedpointer_impl.h:696
        view = 0x0
        screen = 0x556fb2436b50
        knownScreen = <optimized out>
        __for_range = @0x7ffd15385e18: {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        managedScreens = {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        screens = {q_hash = {{d = 0x7f928c5765c0 <QHashData::shared_null>, e = 0x7f928c5765c0 <QHashData::shared_null>}}}
#6  QPointer<QScreen>::data() const (this=0x58) at /usr/include/qt/QtCore/qpointer.h:77
        view = 0x0
        screen = 0x556fb2436b50
        knownScreen = <optimized out>
        __for_range = @0x7ffd15385e18: {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        managedScreens = {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        screens = {q_hash = {{d = 0x7f928c5765c0 <QHashData::shared_null>, e = 0x7f928c5765c0 <QHashData::shared_null>}}}
#7  QPointer<QScreen>::operator QScreen*() const (this=0x58) at /usr/include/qt/QtCore/qpointer.h:83
        view = 0x0
        screen = 0x556fb2436b50
        knownScreen = <optimized out>
        __for_range = @0x7ffd15385e18: {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        managedScreens = {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        screens = {q_hash = {{d = 0x7f928c5765c0 <QHashData::shared_null>, e = 0x7f928c5765c0 <QHashData::shared_null>}}}
#8  DesktopView::screenToFollow() const (this=0x0) at /usr/src/debug/plasma-workspace/plasma-workspace-5.27.4.1/shell/desktopview.cpp:124
        view = 0x0
        screen = 0x556fb2436b50
        knownScreen = <optimized out>
        __for_range = @0x7ffd15385e18: {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        managedScreens = {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        screens = {q_hash = {{d = 0x7f928c5765c0 <QHashData::shared_null>, e = 0x7f928c5765c0 <QHashData::shared_null>}}}
#9  ShellCorona::screenInvariants() const (this=0x556fb24b6fd0) at /usr/src/debug/plasma-workspace/plasma-workspace-5.27.4.1/shell/shellcorona.cpp:828
        view = 0x0
        screen = 0x556fb2436b50
--Type <RET> for more, q to quit, c to continue without paging--c
        knownScreen = <optimized out>
        __for_range = @0x7ffd15385e18: {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        managedScreens = {q_hash = {{d = 0x557207a20290, e = 0x557207a20290}}}
        screens = {q_hash = {{d = 0x7f928c5765c0 <QHashData::shared_null>, e = 0x7f928c5765c0 <QHashData::shared_null>}}}
#10 ShellCorona::screenInvariants() const (this=0x556fb24b6fd0) at /usr/src/debug/plasma-workspace/plasma-workspace-5.27.4.1/shell/shellcorona.cpp:808
#11 0x00007f928c4beb41 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffd15385f80, r=<optimized out>, this=0x556fb24e6a20, this=<optimized out>, r=<optimized out>, a=<optimized out>)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
        receiver = <optimized out>
        td = <optimized out>
        receiverInSameThread = <optimized out>
        senderData = {previous = 0x0, receiver = 0x556fb24b6fd0, sender = 0x556fb24b70f8, signal = 3}
        c = 0x556fb278bf70
        connections = {d = 0x556fb2786bc0}
        list = <optimized out>
        inSenderThread = true
        highestConnectionId = 1
        signalVector = 0x556fb298f610
        currentThreadId = 0x7f928761af80
        sp = <optimized out>
        signal_spy_set = 0x0
        empty_argv = {0x0}
        senderDeleted = false
Comment 2 Nate Graham 2023-04-13 19:21:28 UTC
*** Bug 466095 has been marked as a duplicate of this bug. ***
Comment 3 Nate Graham 2023-04-13 19:21:37 UTC
A few questions for you:
1. Does it happen if you temporarily disable the KScreen2 service in System Settings > Startup & Shutdown > Background Services
2. Does the screen being unplugged have a high refresh rate?
3. Does the screen being unplugged have AdaptiveSync?
Comment 4 yurapostates 2023-04-13 19:39:46 UTC
(In reply to Nate Graham from comment #1)
> What kind of cable is the monitor connected with?
The screens where this issue is happening had DisplayPort-to-HDMI adapters (DisplayPort from GPU side HDMI to screen side). 
But now that you've mentioned it, I tried plugging/unplugging a screen that's connected to the GPU's only HDMI port (screen's also HDMI) and it didn't crash at all.

(In reply to Nate Graham from comment #3)
> A few questions for you:
> 1. Does it happen if you temporarily disable the KScreen2 service in System
> Settings > Startup & Shutdown > Background Services
Yes, it does.
These are the exact steps I followed: KScreen 2 was unticked but it was "Running". I pressed the Pause button and it changed to "Not running". After that I tried to plug/unplug the screens, the screen with the DisplayPort-to-HDMI adapter crashed again. The HDMI one didn't.
> 2. Does the screen being unplugged have a high refresh rate?
Nope. Both screens have 60Hz refresh rate.
> 3. Does the screen being unplugged have AdaptiveSync?
I'm assuming you're referring to FreeSync. Two of the screens that have DisplayPort-to-HDMI adapter, one supports FreeSync the other doesn't. Both showed this issue.
Comment 5 Nate Graham 2023-04-14 15:55:21 UTC
Thanks for the info!
Comment 6 Nate Graham 2023-04-14 15:55:26 UTC
*** Bug 467756 has been marked as a duplicate of this bug. ***
Comment 7 nyanpasu64 2023-04-20 07:29:46 UTC
After getting this plasmashell segfault multiple times a day (after leaving my computer idle so KDE locks and blanks screens, then coming back), I have some observations:

- `ShellCorona::screenInvariants()` is the direct cause of the crash, calling `QScreen *screen = view->screenToFollow();` on a null pointer `const DesktopView *view = desktopForScreen(knownScreen);`. Fascinatingly, in Qt Creator, `ShellCorona::screenInvariants()` is only enabled in debug builds (disabled in release builds with NDEBUG set).
- `desktopForScreen` can return null in normal operation. All other calls to this function (aside from `ShellCorona::screenInvariants()`) check for nullptr return, except that `ShellCorona::color()` calls it once, checks for null pointer, and if not calls it *again* and relies on the function returning a non-null value the second time.
- Is the function supposed to return null after screen blanking and then moving my mouse? I don't know.

Screen layout:

nyanpasu64@ryzen ~/.ssh> kscreen-doctor -o
Output: 68 DP-1 enabled connected priority 1 DisplayPort Modes: 74:2560x1440@60*! 75:2560x1440@75 76:1920x1440@75 77:1920x1440@60 78:1856x1392@75 79:1856x1392@60 80:1792x1344@75 81:1792x1344@60 82:2048x1152@60 83:2048x1152@60 84:2048x1152@60 85:1920x1200@60 86:1920x1200@60 87:1920x1080@60 88:1920x1080@60 89:1920x1080@60 90:1920x1080@60 91:1920x1080@50 92:1920x1080@60 93:1920x1080@60 94:1600x1200@60 95:1600x1200@75 96:1600x1200@70 97:1600x1200@65 98:1600x1200@60 99:1680x1050@60 100:1680x1050@60 101:1400x1050@75 102:1400x1050@60 103:1600x900@60 104:1600x900@60 105:1600x900@60 106:1600x900@60 107:1280x1024@75 108:1280x1024@70 109:1280x1024@60 110:1440x900@60 111:1400x900@60 112:1400x900@60 113:1280x960@60 114:1440x810@60 115:1440x810@60 116:1368x768@60 117:1368x768@60 118:1280x800@60 119:1280x800@60 120:1280x800@60 121:1280x800@60 122:1280x800@60 123:1152x864@75 124:1280x720@60 125:1280x720@60 126:1280x720@60 127:1280x720@60 128:1280x720@50 129:1280x720@60 130:1280x720@60 131:1024x768@75 132:1024x768@60 133:1024x768@75 134:1024x768@70 135:1024x768@60 136:960x720@75 137:960x720@60 138:928x696@75 139:928x696@60 140:896x672@75 141:896x672@60 142:1024x576@60 143:1024x576@60 144:1024x576@60 145:1024x576@60 146:960x600@60 147:960x600@60 148:832x624@75 149:960x540@60 150:960x540@60 151:960x540@60 152:960x540@60 153:800x600@75 154:800x600@70 155:800x600@65 156:800x600@60 157:800x600@72 158:800x600@75 159:800x600@60 160:800x600@56 161:840x525@60 162:840x525@60 163:864x486@60 164:864x486@60 165:720x576@50 166:700x525@75 167:700x525@60 168:800x450@60 169:800x450@60 170:720x480@60 171:720x480@60 172:640x512@75 173:640x512@60 174:700x450@60 175:700x450@60 176:640x480@60 177:640x480@75 178:640x480@73 179:640x480@67 180:640x480@60 181:640x480@60 182:720x405@60 183:720x405@59 184:720x400@70 185:684x384@60 186:684x384@60 187:640x400@60 188:640x400@60 189:576x432@75 190:640x360@60 191:640x360@60 192:640x360@60 193:640x360@59 194:512x384@75 195:512x384@70 196:512x384@60 197:512x288@60 198:512x288@60 199:416x312@75 200:480x270@60 201:480x270@60 202:400x300@72 203:400x300@75 204:400x300@60 205:400x300@56 206:432x243@60 207:432x243@60 208:320x240@73 209:320x240@75 210:320x240@60 211:360x202@60 212:360x202@59 213:320x180@60 214:320x180@59 Geometry: 0,0 2560x1440 Scale: 1 Rotation: 1 Overscan: 0 Vrr: incapable RgbRange: unknown
Output: 69 DP-2 disabled disconnected priority 0 DisplayPort Modes: Geometry: 0,0 0x0 Scale: 1 Rotation: 1 Overscan: 0 Vrr: incapable RgbRange: unknown
Output: 70 HDMI-1 enabled connected priority 2 HDMI Modes: 88:1920x1080@60 90:1920x1080@60*! 93:1920x1080@60 99:1680x1050@60 100:1680x1050@60 101:1400x1050@75 102:1400x1050@60 105:1600x900@60 106:1600x900@60 107:1280x1024@75 109:1280x1024@60 111:1400x900@60 112:1400x900@60 113:1280x960@60 115:1440x810@60 116:1368x768@60 117:1368x768@60 119:1280x800@60 120:1280x800@60 121:1280x800@60 122:1280x800@60 123:1152x864@75 124:1280x720@60 125:1280x720@60 126:1280x720@60 130:1280x720@60 131:1024x768@75 132:1024x768@60 133:1024x768@75 134:1024x768@70 135:1024x768@60 136:960x720@75 137:960x720@60 138:928x696@75 139:928x696@60 140:896x672@75 141:896x672@60 142:1024x576@60 143:1024x576@60 144:1024x576@60 145:1024x576@60 146:960x600@60 147:960x600@60 148:832x624@75 149:960x540@60 150:960x540@60 151:960x540@60 152:960x540@60 153:800x600@75 154:800x600@70 155:800x600@65 156:800x600@60 157:800x600@72 158:800x600@75 159:800x600@60 160:800x600@56 161:840x525@60 162:840x525@60 163:864x486@60 164:864x486@60 166:700x525@75 167:700x525@60 168:800x450@60 169:800x450@60 172:640x512@75 173:640x512@60 174:700x450@60 175:700x450@60 176:640x480@60 177:640x480@75 178:640x480@73 181:640x480@60 182:720x405@60 183:720x405@59 184:720x400@70 185:684x384@60 186:684x384@60 187:640x400@60 188:640x400@60 189:576x432@75 190:640x360@60 191:640x360@60 192:640x360@60 193:640x360@59 194:512x384@75 195:512x384@70 196:512x384@60 197:512x288@60 198:512x288@60 199:416x312@75 200:480x270@60 201:480x270@60 202:400x300@72 203:400x300@75 204:400x300@60 205:400x300@56 206:432x243@60 207:432x243@60 208:320x240@73 209:320x240@75 210:320x240@60 211:360x202@60 212:360x202@59 213:320x180@60 214:320x180@59 215:1680x1050@60 216:1440x900@60 217:1280x800@60 218:1280x720@60 1913:640x480@60 Geometry: 2560,0 1080x1920 Scale: 1 Rotation: 2 Overscan: 0 Vrr: incapable RgbRange: unknown
Output: 71 HDMI-2 disabled disconnected priority 0 HDMI Modes: Geometry: 0,0 0x0 Scale: 1 Rotation: 1 Overscan: 0 Vrr: incapable RgbRange: unknown
Output: 72 DVI-D-1 disabled disconnected priority 0 DVI Modes: Geometry: 0,0 0x0 Scale: 1 Rotation: 1 Overscan: 0 Vrr: incapable RgbRange: unknown

(please ignore `1913:640x480@60`, that's a custom mode added by a xrandr manager I'm developing at https://codeberg.org/nyanpasu64/auto-modeline)

DP-1 is my main display, HDMI-1 is my second display hooked up vertically, and DP-2 is a DP-to-VGA converter connected to no monitor at the time of the plasmashell crash. The crash occurred after the screen locked, blanked, and woke up.

I've managed to reproduce this issue using:

- Check "Manually block sleep and screen locking" (not sure if the issue reproduces without this)
- Lock the screen
- Wait for monitors to go black with a mouse cursor, then turn off
- Move the mouse to wake up the monitors (and crash plasmashell), then log in and run coredumpctl to find a crashed plasmashell.
Comment 8 Harald Sitter 2023-04-20 10:48:04 UTC
Should be fixed by https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2841
Comment 9 Guillaume Castagnino 2023-04-22 05:14:46 UTC
Confirmed fixed for me with both https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2841 AND https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2842

The first MR made the initial backtrace disappear, but there was a second one behind, fixed by the second MR.