Bug#508375: the statement "gdk-pixbuf library does not need to be initialized" is wrong

David Madore david.madore at ens.fr
Wed Dec 10 16:01:09 UTC 2008

Package: libgtk2.0-dev
Version: 2.12.11-4

The page <URL: file:///usr/share/gtk-doc/html/gdk-pixbuf/apas02.html
 >, or, alternatively, <URL:
http://library.gnome.org/devel/gdk-pixbuf/2.12/apas02.html > contains
the statement: "The gdk-pixbuf library does not need to be
initialized".  This is false, as the following trivial program shows:

/* --- cut after --- */
#include <stdio.h>
#include <stdlib.h>

#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

/* Compile with
gcc -o stupid stupid.c -O6 -Wall -std=c99 -Wextra `pkg-config --cflags --libs gdk-pixbuf-2.0`

#define WIDTH 320
#define HEIGHT 240

unsigned char image[HEIGHT][ROWSTRIDEPX][3];

GdkPixbuf *img;

main (void)
  img = gdk_pixbuf_new_from_data ((const guchar *)image,
				  NULL, NULL);
  exit (EXIT_SUCCESS);
/* --- cut before --- */

This program causes a segmentation fault after the following

(process:9342): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9342): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9342): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
zsh: segmentation fault  ./stupid

This segfault goes away when gdk_init() or gtk_init() is used, so it
seems to be an initialization problem: either the doc is wrong, in
which case it should be corrected to explain how and when the library
should be initialized, or it's a gdk-pixbuf bug.

I would prefer this to be counted as a bug against gdk-pixbuf, because
there ought to be a way to manipulate in-core pixbufs (to save image
files to disk) without linking in gdk or gtk.

     David A. Madore
    (david.madore at ens.fr,
     http://www.madore.org/~david/ )

More information about the pkg-gnome-maintainers mailing list