GNOME Bugzilla – Bug 696505
Segfault on Windows x64: gtkstatusicon.c tries to put 64-bit pointer in 32-bit uint
Last modified: 2015-02-21 14:50:53 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.
GtkStatusIcon has been deprecated
Created attachment 297496 [details] [review] statusicon: fix crash storing pointer in UINT
Matthias please consider this patch since it fixes a crash.
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.
Attachment 297496 [details] pushed as f07677c - statusicon: fix crash storing pointer in UINT