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 562084 - [PATCH] Seahorse crashes on 64-bit platforms
[PATCH] Seahorse crashes on 64-bit platforms
Status: RESOLVED FIXED
Product: seahorse
Classification: Applications
Component: general
2.24.x
Other FreeBSD
: Normal blocker
: 2.26.0
Assigned To: Seahorse Maintainer
Seahorse Maintainer
Depends on:
Blocks:
 
 
Reported: 2008-11-24 02:52 UTC by Joe Marcus Clarke
Modified: 2009-02-09 17:58 UTC
See Also:
GNOME target: 2.24.x
GNOME version: 2.23/2.24


Attachments
Fix crash on 64-bit platforms (3.98 KB, patch)
2008-11-24 02:52 UTC, Joe Marcus Clarke
reviewed Details | Review

Description Joe Marcus Clarke 2008-11-24 02:52:01 UTC
Seahorse will crash during initialization on 64-bit platforms.  The stack trace is:

  • #0 IA__g_type_fundamental
    at gtype.c line 3680
  • #1 IA__g_object_new
    at gobject.c line 1053
  • #2 seahorse_viewer_constructor
    at seahorse-viewer.c line 565
  • #3 seahorse_key_manager_constructor
    at seahorse-key-manager.c line 1144
  • #4 IA__g_object_newv
    at gobject.c line 1211
  • #5 seahorse_key_manager_show
    at seahorse-key-manager.c line 209
  • #6 main
    at main.c line 101

The reason for this is that when a module registers its GTypes with the seahorse registry, those 64-bit GTypes are truncated to 32-bit unsigned integers.  When the GTypes are later retrieved, they no longer mapped to registered GObjects.

Attached is a patch which encapsulates the GTypes into a struct.  This patch is incomplete as it would require some vala work as well.  However, it is a proof-of-concept of a fix which works.
Comment 1 Joe Marcus Clarke 2008-11-24 02:52:37 UTC
Created attachment 123298 [details] [review]
Fix crash on 64-bit platforms
Comment 2 Tommi Asiala 2008-12-06 09:18:49 UTC
Thank you for reporting this, but I can not reproduced it on a 64 bit platform. Could you provide more information on what is needed to reproduce this?
Comment 3 Joe Marcus Clarke 2008-12-06 17:58:49 UTC
I think it's pretty clear that the code is wrong.  If you look at how GType is defined:

#if     GLIB_SIZEOF_SIZE_T != GLIB_SIZEOF_LONG || !defined __cplusplus
typedef gsize                           GType;
#else   /* for historic reasons, C++ links against gulong GTypes */
typedef gulong                          GType;
#endif

It's clear that GType is 8 bytes long on 64-bit platforms.  However, you are using GUINT_TO_POINTER to convert this value to a pointer.  The GUINT_TO_POINTER documentation is clear that this macro will not work on 64-bit types.

In order to reproduce this, the GType values must be greater than 2^32-1.  I am able to reliably reproduce this on my amd64 FreeBSD system.  However, on other systems, the GType values may come in below the cutoff.
Comment 4 André Klapper 2009-01-27 16:26:31 UTC
Adam: ping
Comment 5 Adam Schreiber 2009-01-27 17:11:51 UTC
At first blush, this patch looks good.  However, there's been some more refactoring work and vala use has been eliminated.  Could you please clean up the patch so that it applies cleanly to TRUNK and still fixes the issue?
Comment 6 Joe Marcus Clarke 2009-01-27 17:18:56 UTC
I'm currently not using trunk, and I don't have any vala experience.  The patch applied when I first submitted the bug, but even then I admitted someone with vala experience would need to shape it up.
Comment 7 Adam Schreiber 2009-01-27 17:30:56 UTC
I'm saying that vala experience is no longer required.
Comment 8 Simon McVittie 2009-02-08 13:20:59 UTC
The same issue has been reported in telepathy-gabble. I think we could fix this in a less intrusive way by using GPOINTER_TO_SIZE and GSIZE_TO_POINTER to avoid the truncation.
Comment 9 Stef Walter 2009-02-08 14:01:04 UTC
Nice catch guys. 

I've committed a fix based on GSIZE_TO_POINTER. I couldn't duplicate this on my system, so I'd appreciate any verification that this actually fixes the problem.

Much appreciated.
Comment 10 Joe Marcus Clarke 2009-02-09 17:58:26 UTC
Thanks to the telepathy-gabble devs.  I didn't known GPOINTER_TO_SIZE was a valid macro.  Last I looked, I recall only seeing the INT variants.