Registry: don't destroy the callback on globalsync

Authored by dvratil on Feb 21 2020, 11:54 AM.

Description

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

Details

Committed
dvratilFeb 21 2020, 11:54 AM
Reviewer
KWin
Differential Revision
D27538: Registry: don't destroy the callback on globalsync
Parents
R127:a2d0920ba736: Use ecm_qt_install_logging_categories over manual categories file
Branches
Unknown
Tags
Unknown