Skip to content

Only try unset surface if native window is alive

Yifan Zhu requested to merge work/fanzhuyifan/fix into master

Sometimes WindowShadow::internalDestroy is called when the window is being destroyed. In that case, recreating the window in surfaceForWindow(...) causes segfault. Only call surfaceForWindow and unset the surface if the native window is alive.

CCBUG: 478990

Examining the backtraces reported in 478990, we see that the problem seems to be QWindow::create being called on a window that is being destroyed in its destructor:

#15 0x00007f2754000ea5 in QWindowPrivate::create(bool, unsigned long long) (this=0x55cbff19c5c0, recursive=recursive@entry=false, nativeHandle=nativeHandle@entry=0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.7.0-beta1/src/gui/kernel/qwindow.cpp:549
#16 0x00007f2754001741 in QWindow::create() (this=<optimized out>) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.7.0-beta1/src/gui/kernel/qwindow.cpp:716
#17 0x00007f274dac7edd in surfaceForWindow(QWindow*) (window=0x55cc0056eb30) at /usr/src/debug/kwindowsystem/kwindowsystem-5.247.0/src/platforms/wayland/surfacehelper.h:26
...
#25 0x00007f2754006595 in QWindowPrivate::destroy() (this=0x55cbff19c5c0) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.7.0-beta1/src/gui/kernel/qwindow.cpp:2086
#26 0x00007f2754001b32 in QWindow::~QWindow() (this=0x55cc0056eb30, this=<optimized out>) at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.7.0-beta1/src/gui/kernel/qwindow.cpp:185

After this commit, 478990 seems to be reduced to 477233 -- plasmashell still crashes, but with the backtrace in 477233.

Edited by Yifan Zhu

Merge request reports

Loading