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 470161 - gdk_event_copy() doesn't duplicate event->axes for GDK_2BUTTON_PRESS
gdk_event_copy() doesn't duplicate event->axes for GDK_2BUTTON_PRESS
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
2.11.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on: 65877
Blocks:
 
 
Reported: 2007-08-25 10:34 UTC by Denis Auroux
Modified: 2011-08-29 04:18 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16



Description Denis Auroux 2007-08-25 10:34:25 UTC
Steps to reproduce:
In a GTK+ application that enables extension input events, GDK_2BUTTON_PRESS events from input extension devices are received with an invalid "axes" field (non-null, points into g_free'd memory). If an application modifies the axes field of the event structure as part of its input event processing, this leads to memory corruption and eventual crash.
 
Such a situation occurs e.g. with GTK+ 2.11.6 and Xournal 0.4 (not sure why earlier versions of GTK+ don't exhibit the same problem). See http://sourceforge.net/tracker/index.php?func=detail&aid=1780877&group_id=163434&atid=827733
for details.

The relevant point is that, when a GDK_2BUTTON_PRESS event is generated for an XInput device, its axes member points to an invalid memory location because gdk_synthesize_click() enqueues a GDK_2BUTTON_PRESS "clone" of the GDK_BUTTON_PRESS event (by calling gdk_display_put_event(), which in turns calls gdk_event_copy()); but gdk_event_copy() duplicates the "axes" field only for GDK_BUTTON_PRESS, not for GDK_2BUTTON_PRESS. The enqueued GDK_2BUTTON_PRESS event therefore references a memory location that will be freed once processing of the original GDK_BUTTON_PRESS event is complete.


Stack trace:
Stack trace is more confusing than helpful due to complicated interplay between GDK, guest application's event processing loop, and GLib memory allocation.
See above for specific discussion of the bug.

Other information:
This is related to bug #65877 (GTK+ 1.x).
Comment 1 Denis Auroux 2007-08-25 10:45:24 UTC
Looking further at gdk/gdkevents.c, it seems implicit throughout that  GDK_2BUTTON_PRESS/GDK_3BUTTON_PRESS events don't have axes. That's a very reasonable choice, but then it'd be better if gdk_synthesize_click() did set the axes field to NULL, and if the documentation of the GdkEventButton structure mentioned this explicitly.
Comment 2 Tim Janik 2007-08-29 14:29:47 UTC
right, already discussed in http://bugzilla.gnome.org/show_bug.cgi?id=65877#c8. we're waiting fir an updated patch tehre though.
Comment 3 Matthias Clasen 2011-08-29 04:18:33 UTC
axes are getting copied nowadays