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 696505 - Segfault on Windows x64: gtkstatusicon.c tries to put 64-bit pointer in 32-bit uint
Segfault on Windows x64: gtkstatusicon.c tries to put 64-bit pointer in 32-bi...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkStatusIcon
2.24.x
Other Windows
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-03-24 19:31 UTC by Arnav Singh
Modified: 2015-02-21 14:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
statusicon: fix crash storing pointer in UINT (2.20 KB, patch)
2015-02-21 14:05 UTC, Ignacio Casal Quinteiro (nacho)
accepted-commit_now Details | Review

Description Arnav Singh 2013-03-24 19:31:37 UTC
While making builds of Hexchat (an IRC client that uses GTK) for Windows, I've run into a snag. In the file gtkstatusicon.c, the function

    gtk_status_icon_init(GtkStatusIcon *status_icon)

has this line:

    priv->nid.uID = GPOINTER_TO_UINT (status_icon);

where priv->nid is a NOTIFYICONDATAW ( http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352 ) and nid.uID is a UINT.

On Windows x64, uint's are only 32 bits in size, so this assignment loses the upper 32-bits of the pointer. Later, when this pointer is dereferenced in wndproc(), this causes a segfault.

This is GTK 2.24.17

I asked on #gtk+ about this, and walters said GPOINTER_TO_UINT is only supposed to be used on something which should have fit in a uint in the first place. The status_icon pointer on Windows 7 does always seem to have all zeros in the upper 32 bits, but the same pointer in Windows 8 always has something in the upper 32 bits, so it seems it happens to work on Windows 7 only because of a coincidence.
Comment 1 Matthias Clasen 2014-08-30 05:20:42 UTC
GtkStatusIcon has been deprecated
Comment 2 Ignacio Casal Quinteiro (nacho) 2015-02-21 14:05:43 UTC
Created attachment 297496 [details] [review]
statusicon: fix crash storing pointer in UINT
Comment 3 Ignacio Casal Quinteiro (nacho) 2015-02-21 14:06:30 UTC
Matthias please consider this patch since it fixes a crash.
Comment 4 Matthias Clasen 2015-02-21 14:46:42 UTC
Review of attachment 297496 [details] [review]:

Other than that, looks fine to me

::: gtk/deprecated/gtkstatusicon.c
@@ +694,3 @@
 static UINT taskbar_created_msg = 0;
 static GSList *status_icons = NULL;
+static UINT status_icon_id = -1;

I would make this start at 0, given that it is a UINT.
Comment 5 Ignacio Casal Quinteiro (nacho) 2015-02-21 14:50:53 UTC
Attachment 297496 [details] pushed as f07677c - statusicon: fix crash storing pointer in UINT