Registry: don't destroy the callback on globalsync
ClosedPublic

Authored by dvratil on Feb 21 2020, 9:25 AM.

Details

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

Diff Detail

Repository
R127 KWayland
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dvratil created this revision.Feb 21 2020, 9:25 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 21 2020, 9:25 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
dvratil requested review of this revision.Feb 21 2020, 9:25 AM
dvratil edited the summary of this revision. (Show Details)Feb 21 2020, 9:25 AM
zzag accepted this revision.Feb 21 2020, 10:57 AM
zzag added a subscriber: zzag.

Thanks.

This revision is now accepted and ready to land.Feb 21 2020, 10:57 AM
This revision was automatically updated to reflect the committed changes.