Bug 453320 - kwin_wayland DRM backend crashes on simpledrm again
Summary: kwin_wayland DRM backend crashes on simpledrm again
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-02 22:04 UTC by bluescreenavenger
Modified: 2022-05-10 21:20 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bluescreenavenger 2022-05-02 22:04:31 UTC
Hi

It seems that kwin_wayland crash again. Below is the full stack trace

```
#0  KWin::DrmBuffer::modifier (this=0x0) at /srcbuild/kwin/src/backends/drm/drm_buffer.cpp:55
No locals.
#1  0x00007f983fccdb53 in KWin::DrmPipeline::pruneModifier (this=this@entry=0x560c11004030)
    at /opt/include/QtCore/qsharedpointer_impl.h:301
        modifiers = <optimized out>
#2  0x00007f983fcc6f92 in KWin::DrmGpu::checkCrtcAssignment (this=this@entry=0x560c10ecfd20, connectors=..., crtcs=...)
    at /srcbuild/kwin/src/backends/drm/drm_gpu.cpp:379
        crtcsLeft = {d = 0x560c114afa20}
        id = <optimized out>
        it = 0x7fff08fe53f0
        __PRETTY_FUNCTION__ = "bool KWin::DrmGpu::checkCrtcAssignment(QVector<KWin::DrmConnector*>, const QVector<KWin::DrmCrtc*>&)"
        connector = 0x560c114aace0
        pipeline = 0x560c11004030
        currentCrtc = 0x560c10f56690
#3  0x00007f983fcc7238 in KWin::DrmGpu::testPendingConfiguration (this=this@entry=0x560c10ecfd20)
    at /srcbuild/kwin/src/backends/drm/drm_gpu.cpp:419
        connectors = {d = 0x560c114af980}
        crtcs = {d = 0x560c10f4c9f0}
#4  0x00007f983fcc87e7 in KWin::DrmGpu::updateOutputs (this=this@entry=0x560c10ecfd20)
    at /srcbuild/kwin/src/backends/drm/drm_gpu.cpp:319
        resources = {d = <optimized out>}
        __PRETTY_FUNCTION__ = "bool KWin::DrmGpu::updateOutputs()"
        lessees = <optimized out>
        addedOutputs = {d = 0x560c114abb80}
        removedConnectors = {d = 0x7f98469fb720 <QArrayData::shared_null>}
#5  0x00007f983fcb8246 in KWin::DrmBackend::updateOutputs (this=0x560c10e8b970)
    at /srcbuild/kwin/src/backends/drm/drm_backend.cpp:316
        gpu = 0x560c10ecfd20
        it = 0x560c10f3edf8
        oldOutputs = {d = 0x7f98469fb720 <QArrayData::shared_null>}
        __PRETTY_FUNCTION__ = "void KWin::DrmBackend::updateOutputs()"
#6  0x00007f984699940e in ?? () from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#7  0x00007f9847d193a9 in KWin::Compositor::setupStart (this=0x560c10fb4070) at /srcbuild/kwin/src/composite.cpp:324
        supportedCompositors = {d = 0x560c10fb2d80}
        userConfigIt = 0x560c10fb2d98
        __PRETTY_FUNCTION__ = {<optimized out> <repeats 36 times>}
#8  0x00007f9847d193f1 in KWin::WaylandCompositor::start (this=0x560c10fb4070) at /srcbuild/kwin/src/composite.cpp:764
No locals.
#9  0x00007f98469927f4 in QObject::event(QEvent*) () from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#10 0x00007f98460910dd in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /opt/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#11 0x00007f984697bf62 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#12 0x00007f984697c1c9 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#13 0x00007f98469aaf84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#14 0x0000560c0f0dc088 in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
No symbol table info available.
#15 0x00007f9846979afa in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#16 0x00007f984697dcd1 in QCoreApplication::exec() () from /opt/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#17 0x0000560c0f03f1e2 in main (argc=<optimized out>, argv=<optimized out>) at /srcbuild/kwin/src/main_wayland.cpp:657
        environment = {d = {d = 0x560c10e533c0}}
        a = {<KWin::ApplicationWaylandAbstract> = {<KWin::Application> = {<QApplication> = {<No data fields>}, 
              static staticMetaObject = {d = {superdata = {direct = 0x7f9846432f60 <QApplication::staticMetaObject>}, 
                  stringdata = 0x7f9847eeda20 <qt_meta_stringdata_KWin__Application>, 
                  data = 0x7f9847eed8c0 <qt_meta_data_KWin__Application>, 
                  static_metacall = 0x7f9847cf859a <KWin::Application::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, static crashes = 0, 
              m_eventFilters = {<QListSpecialMethods<QPointer<KWin::X11EventFilterContainer> >> = {<No data fields>}, {p = {
                    static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
                              _M_i = -1}, static is_always_lock_free = true}}}, alloc = 0, begin = 0, end = 0, array = {
                        0x0}}, d = 0x7f98469fc1d0 <QListData::shared_null>}, d = 0x7f98469fc1d0 <QListData::shared_null>}}, 
              m_genericEventFilters = {<QListSpecialMethods<QPointer<KWin::X11EventFilterContainer> >> = {<No data fields>}, {
                  p = {static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base<int>> = {
                              static _S_alignment = 4, _M_i = -1}, static is_always_lock_free = true}}}, alloc = 0, 
                      begin = 0, end = 0, array = {0x0}}, d = 0x7f98469fc1d0 <QListData::shared_null>}, 
                  d = 0x7f98469fc1d0 <QListData::shared_null>}}, m_eventFilter = {d = 0x560c10e7bd00}, m_configLock = false, 
              m_config = {d = 0x560c10ec6c70}, m_kxkbConfig = {d = 0x560c10ec6870}, 
              m_operationMode = KWin::Application::OperationModeXwayland, m_x11Time = 0, m_rootWindow = 0, 
              m_connection = 0x0, m_defaultScreen = 0x0, m_useKActivities = true, m_platform = 0x560c10e8b970, 
              m_terminating = false, m_isClosingX11Connection = false}, static staticMetaObject = {d = {superdata = {
                  direct = 0x7f9848031d80 <KWin::Application::staticMetaObject>}, 
                stringdata = 0x7f9847eed880 <qt_meta_stringdata_KWin__ApplicationWaylandAbstract>, 
                data = 0x7f9847eed840 <qt_meta_data_KWin__ApplicationWaylandAbstract>, 
                static_metacall = 0x7f9847cf73c8 <KWin::ApplicationWaylandAbstract::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}, static staticMetaObject = {d = {superdata = {
                direct = 0x7f9848031d40 <KWin::ApplicationWaylandAbstract::staticMetaObject>}, 
              stringdata = 0x560c0f0de2e0 <qt_meta_stringdata_KWin__ApplicationWayland>, 
              data = 0x560c0f0de2a0 <qt_meta_data_KWin__ApplicationWayland>, 
              static_metacall = 0x560c0f040916 <KWin::ApplicationWayland::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, m_startXWayland = true, 
          m_applicationsToStart = {<QList<QString>> = {<QListSpecialMethods<QString>> = {<No data fields>}, {p = {
                  static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base<int>> = {static _S_alignment = 4, 
                            _M_i = -1}, static is_always_lock_free = true}}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, 
                  d = 0x7f98469fc1d0 <QListData::shared_null>}, 
                d = 0x7f98469fc1d0 <QListData::shared_null>}}, <No data fields>}, m_inputMethodServerToStart = {
            static null = {<No data fields>}, d = 0x7f98469fb720 <QArrayData::shared_null>}, m_environment = {d = {
              d = 0x560c10e533c0}}, m_sessionArgument = {static null = {<No data fields>}, 
            d = 0x7f98469fb720 <QArrayData::shared_null>}, m_xwayland = 0x0, m_xwaylandListenFds = {d = 0x7f983800f710}, 
          m_xwaylandDisplay = {static null = {<No data fields>}, d = 0x560c10e8b640}, m_xwaylandXauthority = {
            static null = {<No data fields>}, d = 0x560c10e8b0d0}, m_settingsWatcher = {value = 0x0, d = 0x0}}
        availablePlugins = {d = 0x560c10e7d260}
        hasPlugin = {__availablePlugins = @0x7fff08fe5b08}
        hasSizeOption = <optimized out>
        hasOutputCountOption = 8
        hasX11Option = true
        hasVirtualOption = true
        hasWaylandOption = true
        hasDrmOption = <optimized out>
        xwaylandOption = {d = {d = 0x560c10e8d900}}
        waylandSocketOption = {d = {d = 0x560c10e7c890}}
        x11DisplayOption = {d = {d = 0x560c10e8ebf0}}
        waylandDisplayOption = {d = {d = 0x560c10e8ea70}}
        virtualFbOption = {d = {d = 0x560c10e92550}}
        widthOption = {d = {d = 0x560c10eb3840}}
        heightOption = {d = {d = 0x560c10e8eab0}}
        scaleOption = {d = {d = 0x560c10e8ec30}}
        outputCountOption = {d = {d = 0x560c10e92590}}
        waylandSocketFdOption = {d = {d = 0x560c10e61c60}}
        xwaylandListenFdOption = {d = {d = 0x560c10e8e830}}
        xwaylandDisplayOption = {d = {d = 0x560c10e9c820}}
        xwaylandXAuthorityOption = {d = {d = 0x560c10eb38b0}}
        replaceOption = {d = {d = 0x560c10eb3920}}
        parser = {d = 0x560c10e6bc50}
        drmOption = {d = {d = 0x560c10e8ad50}}
        inputMethodOption = {d = {d = 0x560c10e8adf0}}
        listBackendsOption = {d = {d = 0x560c10e8af50}}
        screenLockerOption = {d = {d = 0x560c10e8aff0}}
        noScreenLockerOption = {d = {d = 0x560c10e8b090}}
        noGlobalShortcutsOption = {d = {d = 0x560c10e8b190}}
        noActivitiesOption = {d = {d = 0x560c10e8b230}}
        exitWithSessionOption = {d = {d = 0x560c10e8b340}}
        pluginName = {static null = {<No data fields>}, 
          d = 0x560c0f0df9a0 <KWin::s_drmPlugin::{lambda()#1}::operator()() const::qstring_literal>}
        initialWindowSize = {wd = <optimized out>, ht = <optimized out>}
        deviceIdentifier = {d = 0x7f98469fb720 <QArrayData::shared_null>}
        outputCount = 150887312
        outputScale = <optimized out>
        pluginIt = 0x7fff08fe5c08
        server = <optimized out>
        flags = {i = 150887416}
        socketName = {static null = {<No data fields>}, d = 0x560c10e8b550}
```

Thanks
Comment 1 bluescreenavenger 2022-05-02 22:12:30 UTC
I mean to say kwin_wayland crashes on simpledrm. I am not sure what commit caused it, but I think a build from a week or two ago worked
Comment 2 Zamundaaa 2022-05-02 23:13:07 UTC
https://invent.kde.org/plasma/kwin/-/merge_requests/2325 should address the crash you're seeing, though I'm not 100% certain it fixes it, as I'm not sure how KWin would get into that state in the first place...
Comment 3 Zamundaaa 2022-05-03 08:57:19 UTC
Git commit 46bbe4ff0cf68b13874b641eca87a9d360fcbfb7 by Xaver Hugl.
Committed on 03/05/2022 at 08:14.
Pushed by zamundaaa into branch 'master'.

backends/drm: don't rely on test commits producing a buffer

When DrmPipeline::commitPipelines returns false without creating a test
buffer, we'd crash.

M  +2    -1    src/backends/drm/drm_pipeline.cpp

https://invent.kde.org/plasma/kwin/commit/46bbe4ff0cf68b13874b641eca87a9d360fcbfb7
Comment 4 bluescreenavenger 2022-05-03 21:49:06 UTC
That fixes the crash, but now it hangs about with a blank screen and it prints some

kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Failed to create a gbm surface!
kwin_wayland_drm: Checking test buffer failed for (0)
kwin_wayland_drm: Failed to find a working setup for new outputs!
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
Comment 5 Zamundaaa 2022-05-03 23:27:27 UTC
Does it work with the environment variable KWIN_DRM_USE_MODIFIERS=0 set?
I suspect that simpledrm supports modifiers, but your gbm implementation does not
Comment 6 bluescreenavenger 2022-05-03 23:38:07 UTC
That works. 
This is the info for simpledrm https://drmdb.emersion.fr/snapshots/bbc4de19efa5

dang, why would my gbm be missing modifier support? That comes from Mesa, correct? 
Maybe something is wrong in the way I built Mesa...
Comment 7 bluescreenavenger 2022-05-03 23:42:56 UTC
the renderer is llvmpipe. I'll explore some Mesa environment variables
Comment 8 bluescreenavenger 2022-05-04 03:06:51 UTC
Sorry about generating more so many comments at once, more investigating with Mesa, one of the only GBM variables is the backend, which the only one I have is the default gbm_dri, no NVIDIA is involved here

I tried setting GALLIUM_DRIVER to softpipe instead of llvmpipe, the other GBM_ALWAYS_SOFTWARE=1, I tried that, that doesn't work as well
Comment 9 bluescreenavenger 2022-05-04 12:27:20 UTC
Sorry, I am spamming this, but I figured out how to get more information, by setting QT_LOGGING_RULES="*=true"

I hope  this info is helpful somewhat 
kwin_scene_opengl: Egl Initialize succeeded
kwin_scene_opengl: EGL version:  1 . 4
kwin_scene_opengl: Created EGL context with attributes: 
Version requested:	true
Version:	3.1
Robust:	false
Reset on video memory purge:	false
Forward compatible:	false
Core profile:	false
Compatibility profile:	false
High priority:	false
kwin_scene_opengl: Created EGL context with attributes: 
Version requested:	true
Version:	3.1
Robust:	false
Reset on video memory purge:	false
Forward compatible:	false
Core profile:	false
Compatibility profile:	false
High priority:	false
OpenGL vendor string:                   Mesa/X.org
OpenGL renderer string:                 llvmpipe (LLVM 11.0.1, 256 bits)
OpenGL version string:                  4.5 (Core Profile) Mesa 21.3.7 (git-d5ec846bc8)
OpenGL shading language version string: 4.50
Driver:                                 LLVMpipe
GPU class:                              Unknown
OpenGL version:                         4.5
GLSL version:                           4.50
Mesa version:                           21.3.7
Linux kernel version:                   5.14.21
Requires strict binding:                no
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
kwin_scene_opengl: Filter multi-plane format 961959257
kwin_scene_opengl: Filter multi-plane format 825316697
kwin_scene_opengl: Filter multi-plane format 842093913
kwin_scene_opengl: Filter multi-plane format 909202777
kwin_scene_opengl: Filter multi-plane format 875713881
kwin_scene_opengl: Filter multi-plane format 961893977
kwin_scene_opengl: Filter multi-plane format 825316953
kwin_scene_opengl: Filter multi-plane format 842094169
kwin_scene_opengl: Filter multi-plane format 909203033
kwin_scene_opengl: Filter multi-plane format 875714137
kwin_scene_opengl: Filter multi-plane format 842094158
kwin_scene_opengl: Filter multi-plane format 909203022
kwin_scene_opengl: EGL driver advertises 29 supported dmabuf formats with modifiers
kwin_core: OpenGL compositing has been successfully initialized
kwin_wayland_drm: Could not find edid for connector DrmConnector(id=31, gpu=KWin::DrmGpu(0x55aa80c52370), name="Unknown-1-unknown", connection="Connected", countMode=1)
kwin_wayland_drm: Connector 31 has properties "CRTC_ID"=34, "non-desktop"=0, "DPMS"=0, "EDID"=0, "overscan" not found, "vrr_capable" not found, "underscan" not found, "underscan vborder" not found, "underscan hborder" not found, "Broadcast RGB" not found, "max bpc" not found, "link-status"="Good"
kwin_wayland_drm: New output on GPU /dev/dri/card0: Unknown-1-unknown
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Failed to create a gbm surface!
kwin_wayland_drm: Checking test buffer failed for (0)
kwin_wayland_drm: Flags: none
kwin_wayland_drm: Drm objects:
kwin_wayland_drm: "connector" 31
kwin_wayland_drm: 	"CRTC_ID": 34
kwin_wayland_drm: 	"non-desktop": 0
kwin_wayland_drm: 	"DPMS": 0
kwin_wayland_drm: 	"EDID": 0
kwin_wayland_drm: 	"link-status": 0
kwin_wayland_drm: "crtc" 34
kwin_wayland_drm: 	"MODE_ID": 41
kwin_wayland_drm: 	"ACTIVE": 1
kwin_wayland_drm: 	"VRR_ENABLED": 0
kwin_wayland_drm: "plane" 32
kwin_wayland_drm: 	"type": 1
kwin_wayland_drm: 	"SRC_X": 0
kwin_wayland_drm: 	"SRC_Y": 0
kwin_wayland_drm: 	"SRC_W": 640
kwin_wayland_drm: 	"SRC_H": 480
kwin_wayland_drm: 	"CRTC_X": 0
kwin_wayland_drm: 	"CRTC_Y": 0
kwin_wayland_drm: 	"CRTC_W": 640
kwin_wayland_drm: 	"CRTC_H": 480
kwin_wayland_drm: 	"FB_ID": 36
kwin_wayland_drm: 	"CRTC_ID": 34
kwin_wayland_drm: 	"IN_FORMATS": 33
kwin_wayland_drm: Failed to find a working setup for new outputs!
kwin_wayland_drm: adding placeholder output
kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x55aa8121adc0, name="Unknown-1", geometry=QRect(0,0 640x480), scale=1)
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Could not create gbm surface! Function not implemented
kwin_wayland_drm: Failed to create a gbm surface!
kwin_wayland_drm: Checking test buffer failed for (0)
kwin_wayland_drm: Flags: none
kwin_wayland_drm: Drm objects:
kwin_wayland_drm: "connector" 31
kwin_wayland_drm: 	"CRTC_ID": 34
kwin_wayland_drm: 	"non-desktop": 0
kwin_wayland_drm: 	"DPMS": 0
kwin_wayland_drm: 	"EDID": 0
kwin_wayland_drm: 	"link-status": 0
kwin_wayland_drm: "crtc" 34
kwin_wayland_drm: 	"MODE_ID": 41
kwin_wayland_drm: 	"ACTIVE": 1
kwin_wayland_drm: 	"VRR_ENABLED": 0
kwin_wayland_drm: "plane" 32
kwin_wayland_drm: 	"type": 1
kwin_wayland_drm: 	"SRC_X": 0
kwin_wayland_drm: 	"SRC_Y": 0
kwin_wayland_drm: 	"SRC_W": 640
kwin_wayland_drm: 	"SRC_H": 480
kwin_wayland_drm: 	"CRTC_X": 0
kwin_wayland_drm: 	"CRTC_Y": 0
kwin_wayland_drm: 	"CRTC_W": 640
kwin_wayland_drm: 	"CRTC_H": 480
kwin_wayland_drm: 	"FB_ID": 36
kwin_wayland_drm: 	"CRTC_ID": 34
kwin_wayland_drm: 	"IN_FORMATS": 33
Comment 10 Zamundaaa 2022-05-05 11:34:26 UTC
https://invent.kde.org/plasma/kwin/-/merge_requests/2335 should fix the problem
Comment 11 bluescreenavenger 2022-05-05 12:03:24 UTC
Cool, that seems to fix it
Comment 12 Zamundaaa 2022-05-10 17:54:03 UTC
Git commit f02a6fd128d83b5e20131d1551c31d47b1332db4 by Xaver Hugl.
Committed on 10/05/2022 at 17:42.
Pushed by zamundaaa into branch 'master'.

backends/drm: add fallback for missing gbm modifier support

It can happen that a gbm implementation does not support modifiers, while
the drm driver does. To prevent that from breaking KWin, fall back to creating
a gbm surface without modifiers when creating one with modifiers fails.

M  +23   -25   src/backends/drm/egl_gbm_layer_surface.cpp
M  +40   -35   src/backends/drm/gbm_surface.cpp
M  +10   -3    src/backends/drm/gbm_surface.h
M  +16   -11   src/backends/drm/virtual_egl_gbm_layer.cpp

https://invent.kde.org/plasma/kwin/commit/f02a6fd128d83b5e20131d1551c31d47b1332db4
Comment 13 bluescreenavenger 2022-05-10 21:20:06 UTC
Thanks! it works!