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 585536 - unique_app_new segfaults if gtk not initialized
unique_app_new segfaults if gtk not initialized
Status: RESOLVED FIXED
Product: libunique
Classification: Other
Component: docs
1.0.x
Other Linux
: Normal normal
: ---
Assigned To: libunique-maint
libunique-maint
Depends on:
Blocks:
 
 
Reported: 2009-06-12 09:17 UTC by Pierre Wieser
Modified: 2009-08-24 21:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Pierre Wieser 2009-06-12 09:17:44 UTC
Hi,

I use libunique 1.0.8 under Gnome 2.24.

I notice that unique_app_new and unique_app_new_with_commands segfault if gtk_init is not called _before_ trying to allocate a new UniqueApp instance.

g_type_init is not enough to avoid this.

Simple code to reproduce :

int
main( int argc, char *argv[] )
{
	/* need to gtk_init before unique_app_new
	 * g_type_init is not enough
	 */
	/*gtk_init( &argc, &argv );*/
	g_type_init();

	UniqueApp *app = unique_app_new( "org.my-domain.MyAppli", NULL );

	g_object_unref( app );

	return( 0 );
}

(gdb) bt
  • #0 IA__gdk_x11_display_get_startup_notification_id
    at gdkdisplay-x11.c line 1437
  • #1 object_set_property
    at gobject.c line 938
  • #2 g_object_constructor
    at gobject.c line 1348
  • #3 ??
    from /usr/lib/libunique-1.0.so.0
  • #4 IA__g_object_newv
    at gobject.c line 1211
  • #5 IA__g_object_new_valist
    at gobject.c line 1315
  • #6 IA__g_object_new
    at gobject.c line 1056
  • #7 unique_app_new
    from /usr/lib/libunique-1.0.so.0
  • #8 main
    at tmain.c line 48

Maybe gtk_init should be called at the very earliest stage of the UI program, even if we don't know yet if we are going to actually run the application.

So I don't know if it is really a bug, but I suggest at least updating the documentation.

Regards,
Pierre

And many thanks for all your work...!
Comment 1 Emmanuele Bassi (:ebassi) 2009-06-12 09:32:45 UTC
the example on the wiki page shows it:

  http://live.gnome.org/LibUnique

the example code in the tarball shows it:

  http://git.gnome.org/cgit/unique/plain/tests/test-unique.c

and unique depends on gtk+, so I assume people will use gtk+ properly.

anyway, I'll add a note in the documentation.
Comment 2 Emmanuele Bassi (:ebassi) 2009-08-24 21:55:47 UTC
fixed in master:

commit a72ab58ea3b6e9ebb2735981c1266c09504c4b17
Author: Emmanuele Bassi <ebassi@gnome.org>
Date:   Mon Aug 24 22:50:21 2009 +0100

    [docs] Add a note about requiring gtk_init()
    
    Be more explicit on requiring GTK+ to be initialized before using
    LibUnique.
    
    Fixes bug:
    
      http://bugzilla.gnome.org/show_bug.cgi?id=585536