Bug 465970 - KWin crashes in XFixesCursorEventFilter
Summary: KWin crashes in XFixesCursorEventFilter
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2023-02-17 23:18 UTC by Natalie Clarius
Modified: 2023-07-24 15:06 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Natalie Clarius 2023-02-17 23:18:49 UTC
Application: kwin_x11 (5.27.80)
 (Compiled from sources)
Qt Version: 5.15.8
Frameworks Version: 5.104.0
Operating System: Linux 6.1.12-arch1-1 x86_64
Windowing System: X11
Distribution: "Arch Linux"
DrKonqi: 5.27.80 [KCrashBackend]

-- Information about the crash:
Since recently,  on each startup KWin crashes with the below backtrace.

The crash can be reproduced every time.

-- Backtrace:
Application: KWin (kwin_x11), signal: Aborted
Content of s_kcrashErrorMessage: std::unique_ptr<char []> = {get() = 0x0}
[KCrash Handler]
#5  0x00007fa49b7b88ec in  () at /usr/lib/libc.so.6
#6  0x00007fa49b769ea8 in raise () at /usr/lib/libc.so.6
#7  0x00007fa49b75353d in abort () at /usr/lib/libc.so.6
#8  0x00007fa49d29fede in qt_assert(char const*, char const*, int) () at /usr/lib/libQt5Core.so.5
#9  0x00007fa49d29ff3c in qt_assert_x(char const*, char const*, char const*, int) () at /usr/lib/libQt5Core.so.5
#10 0x00007fa49f0bfa0a in KWin::kwinApp() () at /home/natalie/kde/src/kwin/src/main.h:383
#11 0x00007fa49f0bfbf1 in KWin::X11EventFilter::~X11EventFilter() (this=0x562d65e54410, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/x11eventfilter.cpp:38
#12 0x0000562d64ba0268 in KWin::XFixesCursorEventFilter::~XFixesCursorEventFilter() (this=0x562d65e54410, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/backends/x11/standalone/x11_standalone_xfixes_cursor_event_filter.h:16
#13 0x0000562d64ba0284 in KWin::XFixesCursorEventFilter::~XFixesCursorEventFilter() (this=0x562d65e54410, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/backends/x11/standalone/x11_standalone_xfixes_cursor_event_filter.h:16
#14 0x0000562d64b8fe1c in std::default_delete<KWin::XFixesCursorEventFilter>::operator()(KWin::XFixesCursorEventFilter*) const (this=0x562d65de9250, __ptr=0x562d65e54410) at /usr/include/c++/12.2.1/bits/unique_ptr.h:95
#15 0x0000562d64b8fabe in std::unique_ptr<KWin::XFixesCursorEventFilter, std::default_delete<KWin::XFixesCursorEventFilter> >::~unique_ptr() (this=0x562d65de9250, __in_chrg=<optimized out>) at /usr/include/c++/12.2.1/bits/unique_ptr.h:396
#16 0x0000562d64b8f118 in KWin::X11Cursor::~X11Cursor() (this=0x562d65de91c0, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/backends/x11/standalone/x11_standalone_cursor.cpp:51
#17 0x0000562d64b8f160 in KWin::X11Cursor::~X11Cursor() (this=0x562d65de91c0, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/backends/x11/standalone/x11_standalone_cursor.cpp:51
#18 0x00007fa49d4b4ba5 in QObjectPrivate::deleteChildren() () at /usr/lib/libQt5Core.so.5
#19 0x00007fa49d4b5369 in QObject::~QObject() () at /usr/lib/libQt5Core.so.5
#20 0x00007fa49ef1c2a3 in KWin::Application::~Application() (this=0x7ffe1ec2d6f0, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/main.cpp:143
#21 0x0000562d64b74a78 in KWin::ApplicationX11::~ApplicationX11() (this=0x7ffe1ec2d6f0, __in_chrg=<optimized out>) at /home/natalie/kde/src/kwin/src/main_x11.cpp:194
#22 0x0000562d64b7638d in main(int, char**) (argc=2, argv=0x7ffe1ec2d8f8) at /home/natalie/kde/src/kwin/src/main_x11.cpp:448
[Inferior 1 (process 39354) detached]

Reported using DrKonqi
Comment 1 Natalie Clarius 2023-02-17 23:28:43 UTC
Also sometimes happens in the middle of a session.
Comment 2 Vlad Zahorodnii 2023-02-20 10:48:26 UTC
I'm confused why kwin quits at startup. Does kwin print anything before quitting?
Comment 3 Natalie Clarius 2023-02-20 13:11:36 UTC
Maybe it has to do with session restoration. I'll try turning that off for a while and see if the crash still occurs.
Comment 4 Natalie Clarius 2023-02-20 13:12:39 UTC
A possibly relevant journal entry from kwin_x11 is:

Feb 20 14:09:10 montague kwin_x11[72612]: ASSERT: "qobject_cast<Application *>(QCoreApplication::instance())" in file /home/natalie/kde/src/kwin/src/main.h, line 383
Feb 20 14:09:10 montague kwin_x11[72612]: QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
Comment 5 Natalie Clarius 2023-02-21 02:07:13 UTC
Also sometimes the same crash happens multiple times in direct succession after logging in.
Comment 6 Natalie Clarius 2023-02-21 15:38:46 UTC
Disabling session restoration does not prevent the crash from happening.
Comment 7 Bug Janitor Service 2023-07-23 20:58:17 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4261
Comment 8 Natalie Clarius 2023-07-23 21:13:05 UTC
I'm no longer experiencing this bug so I'm afraid I can't test if the MR fixes it.
Comment 9 David Edmundson 2023-07-24 15:06:20 UTC
Git commit 35adcfe36a613d5b949fea6f656c343aea57089f by David Edmundson.
Committed on 24/07/2023 at 16:52.
Pushed by davidedmundson into branch 'master'.

delete platform cursor before Application

We want the platform cursor to have roughly the same lifespan as the
application.

By using QObject parent mechanism, this gets deleted after the
Application destructor in the QObject destructor.

This causes an issue that removing an event filter (used by the X11
cursor) calls into the application singleton which is no longer valid.

M  +5    -4    src/backends/x11/standalone/x11_standalone_backend.cpp
M  +2    -1    src/backends/x11/standalone/x11_standalone_backend.h
M  +2    -2    src/backends/x11/standalone/x11_standalone_cursor.cpp
M  +1    -1    src/backends/x11/standalone/x11_standalone_cursor.h
M  +2    -3    src/cursor.cpp
M  +1    -1    src/cursor.h
M  +2    -1    src/input.cpp
M  +3    -3    src/main.cpp
M  +3    -1    src/main.h
M  +3    -2    src/main_x11.cpp
M  +1    -1    src/main_x11.h
M  +2    -2    src/pointer_input.cpp
M  +1    -1    src/pointer_input.h

https://invent.kde.org/plasma/kwin/-/commit/35adcfe36a613d5b949fea6f656c343aea57089f