Commit 33827bbd authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

autotests: Fix internal connection teardown

This might be the root cause of random ASAN errors in testQuickTiling.

From commit 617291c6:

The internal EventQueue is a child of the registry object. This means
that after the registry is destroyed, all proxy objects in that event
queue are going to have invalid reference to it, which is not a problem
as long as the wl_display_dispatch() function is not called.

The wl_display_dispatch() function uses wl_proxy's queue reference to
enqueue incoming events to that queue.

Unfortunately, during teardown, the internal ConnectionThread may
dispatch events right after the registry object has been destroyed,
which can lead to a crash.

In order to fix the crash, we need to destroy all proxy objects and only
after that we can destroy the event queue. It's okay if wayland events
are dispatched in between.

i.e. the EventQueue object must be destroyed last to ensure avoid hitting
dangling pointers.
parent e40bdc90
Pipeline #228873 passed with stage
in 14 minutes and 26 seconds
......@@ -533,8 +533,6 @@ void destroyWaylandConnection()
s_waylandConnection.idleInhibitManagerV1 = nullptr;
delete s_waylandConnection.shm;
s_waylandConnection.shm = nullptr;
delete s_waylandConnection.queue;
s_waylandConnection.queue = nullptr;
delete s_waylandConnection.registry;
s_waylandConnection.registry = nullptr;
delete s_waylandConnection.appMenu;
......@@ -549,6 +547,10 @@ void destroyWaylandConnection()
s_waylandConnection.layerShellV1 = nullptr;
delete s_waylandConnection.outputManagementV2;
s_waylandConnection.outputManagementV2 = nullptr;
delete s_waylandConnection.queue; // Must be destroyed last
s_waylandConnection.queue = nullptr;
if (s_waylandConnection.thread) {
s_waylandConnection.connection->deleteLater();
s_waylandConnection.thread->quit();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment