After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735830 - Pixmap based cursors get surface destroyed after first use
Pixmap based cursors get surface destroyed after first use
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
unspecified
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-09-01 17:25 UTC by Carlos Garnacho
Modified: 2014-09-01 18:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland: Reference pixmap-based cursors' surface before handing the wl_buffer (1.42 KB, patch)
2014-09-01 17:26 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2014-09-01 17:25:32 UTC
When a pixmap-based cursor is set as the current cursor, its wl_buffer goes through the same general machinery than GdkWindow wl_buffers do, which does call cairo_surface_destroy on buffer_release_callback(). These cursors don't account for its only surface reference to be dropped elsewhere, and crashes happen when the cursor gets reused (eg. setting another cursor, and that one back).

I'm attaching a patch that adds a reference to the cairo surface before handing the wl_buffer for rendering, so it behaves similarly to GdkWindows there.
Comment 1 Carlos Garnacho 2014-09-01 17:26:35 UTC
Created attachment 285040 [details] [review]
wayland: Reference pixmap-based cursors' surface before handing the wl_buffer

cairo_surface_destroy() is called after the buffer is released, for every
wl_buffer. Windows usually reference their cairo surface before rendering,
so that extra reference is consumed after the buffer is released, so do
the same with cursor surfaces and add an extra reference whenever a cursor
surface change is about to be scheduled.

Otherwise, the GdkWaylandCursor is left with an invalid cairo_surface_t,
which causes crashes the next time it is used.
Comment 2 Matthias Clasen 2014-09-01 18:18:55 UTC
Review of attachment 285040 [details] [review]:

good catch
Comment 3 Carlos Garnacho 2014-09-01 18:49:03 UTC
Attachment 285040 [details] pushed as a0abdbb - wayland: Reference pixmap-based cursors' surface before handing the wl_buffer