Verified Commit 4ceb3567 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Registry: don't destroy the callback on globalsync

Summary:
Instead just unref it, because the wl_display_dispatch_queue_pending
will try to destroy the callback afterwards as well, leading to
invalid read/write.

Fixes Valgrind warnings when running KScreen tests:
```
==460922== Invalid read of size 4
==460922==    at 0x5CE5B34: wl_proxy_unref (wayland-client.c:230)
==460922==    by 0x5CE5C33: destroy_queued_closure (wayland-client.c:292)
==460922==    by 0x5CE74AB: dispatch_queue (wayland-client.c:1591)
==460922==    by 0x5CE74AB: wl_display_dispatch_queue_pending (wayland-client.c:1833)
==460922==    by 0x4E0240D: KWayland::Client::EventQueue::dispatch() (src/frameworks/kwayland/src/client/event_queue.cpp:96)
g==460922==  Address 0x17233aac is 44 bytes inside a block of size 80 free'd
==460922==    at 0x483B9F5: free (vg_replace_malloc.c:540)
==460922==    by 0x4E15B60: destroy (src/frameworks/kwayland/src/client/wayland_pointer_p.h:63)
==460922==    by 0x4E15B60: KWayland::Client::Registry::Private::globalSync(void*, wl_callback*, unsigned int) (src/frameworks/kwayland/src/client/registry.cpp:548)
...
==460922==    by 0x5CE74AB: dispatch_queue (wayland-client.c:1591)
==460922==    by 0x5CE74AB: wl_display_dispatch_queue_pending (wayland-client.c:1833)
==460922==    by 0x4E0240D: KWayland::Client::EventQueue::dispatch() (src/frameworks/kwayland/src/client/event_queue.cpp:96)
```

Test Plan: Run testkwaylandbackend from libkscreen under Valgrind - no more invalid reads

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D27538
parent a2d0920b
...@@ -545,7 +545,7 @@ void Registry::Private::globalSync(void* data, wl_callback* callback, uint32_t s ...@@ -545,7 +545,7 @@ void Registry::Private::globalSync(void* data, wl_callback* callback, uint32_t s
auto r = reinterpret_cast<Registry::Private*>(data); auto r = reinterpret_cast<Registry::Private*>(data);
Q_ASSERT(r->callback == callback); Q_ASSERT(r->callback == callback);
r->handleGlobalSync(); r->handleGlobalSync();
r->callback.destroy(); r->callback.release();
} }
void Registry::Private::handleGlobalSync() void Registry::Private::handleGlobalSync()
......
Markdown is supported
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