kwin/autotests
Vlad Zagorodniy 826b9742e9 wayland: Terminate client connections before Workspace is destroyed
Summary:
When ShellClient tears down, it needs to access RuleBook in order to
discard temporary rules. The problem is that WaylandServer outlives
Workspace and therefore so does ShellClient.

We can't guard against the case when RuleBook::self() is nullptr as it
is vital to discard temporary rules.

This change adjusts termination sequence so all shell clients are
destroyed before Workspace(and thus RuleBook) is gone.

ASAN output:
    ==19922==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000142060 at pc 0x7fbc0fb878bb bp 0x7ffd7d464520 sp 0x7ffd7d464518
    READ of size 8 at 0x606000142060 thread T0
        #0 0x7fbc0fb878ba in QList<KWin::Rules*>::detach() /usr/include/qt5/QtCore/qlist.h:172
        #1 0x7fbc0fb8538d in QList<KWin::Rules*>::begin() /usr/include/qt5/QtCore/qlist.h:324
        #2 0x7fbc0fb808b6 in KWin::RuleBook::discardUsed(KWin::AbstractClient*, bool) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/rules.cpp:1144
        #3 0x7fbc0fe36e32 in KWin::ShellClient::destroyClient() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/shell_client.cpp:435
        #4 0x7fbc0fe7a726 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWin::ShellClient::*)()>::call(void (KWin::ShellClient::*)(), KWin::ShellClient*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:152
        #5 0x7fbc0fe784c3 in void QtPrivate::FunctionPointer<void (KWin::ShellClient::*)()>::call<QtPrivate::List<>, void>(void (KWin::ShellClient::*)(), KWin::ShellClient*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:185
        #6 0x7fbc0fe74de9 in QtPrivate::QSlotObject<void (KWin::ShellClient::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (/home/jenkins/install-prefix/lib64/libkwin.so.5+0x1677de9)
        #7 0x7fbc04f27357 in QMetaObject::activate(QObject*, int, int, void**) (/usr/lib64/libQt5Core.so.5+0x2b3357)
        #8 0x7fbc074e1970 in KWayland::Server::Resource::unbound() /home/jenkins/workspace/Administration/Dependency Build Plasma kf5-qt5 SUSEQt5.12/kwayland/build/src/server/KF5WaylandServer_autogen/EWIEGA46WW/moc_resource.cpp:142
        #9 0x7fbc0766b4b4 in KWayland::Server::Resource::Private::unbind(wl_resource*) /home/jenkins/workspace/Administration/Dependency Build Plasma kf5-qt5 SUSEQt5.12/kwayland/src/server/resource.cpp:68
        #10 0x7fbc00bdc2ae  (/usr/lib64/libwayland-server.so.0+0x92ae)
        #11 0x7fbc00bdc32f in wl_resource_destroy (/usr/lib64/libwayland-server.so.0+0x932f)
        #12 0x7fbc0766b53f in KWayland::Server::Resource::Private::resourceDestroyedCallback(wl_client*, wl_resource*) /home/jenkins/workspace/Administration/Dependency Build Plasma kf5-qt5 SUSEQt5.12/kwayland/src/server/resource.cpp:76
        #13 0x7fbbff481d8c  (/usr/lib64/libffi.so.7+0x6d8c)
        #14 0x7fbbff481179  (/usr/lib64/libffi.so.7+0x6179)
        #15 0x7fbc00bdfa5f  (/usr/lib64/libwayland-server.so.0+0xca5f)
        #16 0x7fbc00bdc6d1  (/usr/lib64/libwayland-server.so.0+0x96d1)
        #17 0x7fbc00bddc71 in wl_event_loop_dispatch (/usr/lib64/libwayland-server.so.0+0xac71)
        #18 0x7fbc07541e50 in KWayland::Server::Display::Private::dispatch() /home/jenkins/workspace/Administration/Dependency Build Plasma kf5-qt5 SUSEQt5.12/kwayland/src/server/display.cpp:148
        #19 0x7fbc075432de in KWayland::Server::Display::dispatchEvents(int) /home/jenkins/workspace/Administration/Dependency Build Plasma kf5-qt5 SUSEQt5.12/kwayland/src/server/display.cpp:220
        #20 0x7fbc0fe864ca in KWin::WaylandServer::dispatch() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/wayland_server.cpp:616
        #21 0x451ce0 in KWin::WaylandTestApplication::~WaylandTestApplication() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/autotests/integration/kwin_wayland_test.cpp:91
        #22 0x42faa1 in main /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/autotests/integration/globalshortcuts_test.cpp:381
        #23 0x7fbc04796bca in __libc_start_main (/lib64/libc.so.6+0x26bca)
        #24 0x413ea9 in _start (/home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/bin/testGlobalShortcuts+0x413ea9)

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22821
2019-07-31 20:08:50 +03:00
..
drm Port away from deprecated headers 2019-07-09 23:59:07 +03:00
integration wayland: Terminate client connections before Workspace is destroyed 2019-07-31 20:08:50 +03:00
libinput Send axis_source, axis_discrete, and axis_stop 2019-05-17 12:06:10 +03:00
libkwineffects [libkwineffects] Detect modern Radeon GPUs 2018-12-21 13:43:13 +02:00
libxrenderutils
tabbox Use more traditional doxygen style 2019-07-29 22:06:19 +03:00
abstract_client.h Fix minor EBN issues 2018-08-29 21:02:16 +03:00
client.h
CMakeLists.txt [platforms/x11/standalone] Port to AbstractOutput 2019-06-13 11:39:25 +02:00
fakeeffectplugin.cpp Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
fakeeffectplugin.json
fakeeffectplugin_version.cpp Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
fakeeffectplugin_version.json
mock_abstract_client.cpp
mock_abstract_client.h Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
mock_client.cpp
mock_client.h Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
mock_effectshandler.cpp
mock_effectshandler.h Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
mock_screens.cpp
mock_screens.h Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
mock_workspace.cpp Use more accurate name for Workspace::getMovingClient method 2019-04-22 11:12:22 +03:00
mock_workspace.h Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
onscreennotificationtest.cpp
onscreennotificationtest.h
opengl_context_attribute_builder_test.cpp
test_builtin_effectloader.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_client_machine.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_gbm_surface.cpp
test_gestures.cpp
test_plugin_effectloader.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_screen_edges.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_screen_paint_data.cpp
test_screens.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_scripted_effectloader.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_virtual_desktops.cpp autotests: Port QSignalSpies to new connect syntax 2019-07-29 22:59:12 +03:00
test_virtualkeyboard_dbus.cpp Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
test_window_paint_data.cpp Support CriticalNotification type and place it in a CriticalNotificationLayer 2019-05-02 10:29:38 +02:00
test_x11_timestamp_update.cpp Run clang-tidy with modernize-use-override check 2019-07-22 20:03:22 +03:00
test_xcb_size_hints.cpp
test_xcb_window.cpp
test_xcb_wrapper.cpp Fix minor EBN issues 2018-08-29 21:02:16 +03:00
test_xkb.cpp Use more traditional doxygen style 2019-07-29 22:06:19 +03:00
testutils.h Use more traditional doxygen style 2019-07-29 22:06:19 +03:00
workspace.h