[poppler] Segmentation fault when running "poppler_document_new_from_file"

Dominic Lachowicz domlachowicz at gmail.com
Tue Jul 29 13:19:59 PDT 2008


Hi Bart,

> (process:15205): GLib-GObject-CRITICAL **: gtype.c:2248: initialization
> assertion failed, use IA__g_type_init() prior to this function

You need to call g_type_init() inside of main() before you call any
other code that uses GObject.

Cheers,
Dom

On Tue, Jul 29, 2008 at 6:55 AM, bart at pluton.nl <bart at pluton.nl> wrote:
>
> Dear poppler people,
>
> Currently I am trying to develop a program to sort documents. For this
> program I would like to use poppler to render PDF files. I have made the
> following code to try out and gain experience with poppler.
> Unfortunately the results is a segmentation fault :-(. I hope someone
> here can help me solve the problem.
>
> The following messages are returned when executing the function
> "poppler_document_new_from_file":
>
>
> (process:15205): GLib-GObject-CRITICAL **: gtype.c:2248: initialization
> assertion failed, use IA__g_type_init() prior to this function
>
> (process:15205): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (process:15205): GLib-GObject-CRITICAL **: g_object_new: assertion
> `G_TYPE_IS_OBJECT (object_type)' failed
> Segmentation fault
>
>
> The code compiles without errors or warnings with the following command:
>
> "gcc `pkg-config --libs --cflags glib-2.0 gtk+-2.0 poppler poppler-glib
> gdk-2.0 gdk-pixbuf-2.0` test.c -o test"
>
>
> The system in use is Fedora 9 kernel 2.6.25.11-96.fc9.i686 on a dual
> core Intel pentium E2140. The (dev) packages are installed using the
> package manager "gpk-application". I am running Gnome but KDE is
> installed also.
>
> I hope someone has an idea. Maybe it is something really simple which I
> forgot. I thank you for your reply and ideas in advance.
>
> Greetings,
>
>
> Bart
>
>
>
> The CODE:
>
>
> #include <glib.h>
> #include <glib-object.h>
>
> #include <glib/poppler.h>
> #include <glib/poppler-document.h>
> #include <glib/poppler-page.h>
>
> #include <gdk-pixbuf/gdk-pixbuf.h>
>
> #include <gtk/gtk.h>
>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> int main(int   argc,
>         char *argv[])
> {
>
>        GError *error = NULL;
>        GdkPixbuf *pixBuf = NULL;
>
>        gchar *filename_uri = "file:///home/Bart/C/Poppler/test2.pdf";
>
>        printf("DEBUG: line A\n");
>
>
> // Until here every thing is oke
>
>        PopplerDocument *doc = poppler_document_new_from_file (
>                                                        filename_uri,
>                                                        NULL,
>                                                        &error );
>
>
> // This print statement is not visible. The error occurs above it.
>        printf("DEBUG: line B\n");
>
>
>        if( error != NULL )
>        {
>                // Report the error
>                printf("\n\nError: %s\n", &error->message);
>                exit(1);
>        }
>
>        printf("DEBUG: line C\n");
>
>        PopplerPage *page = poppler_document_get_page ( doc,
>                                                        0 );
>
> // The next lines are not functional but should not be the problem
>
>
>        pixBuf = gdk_pixbuf_new ( GDK_COLORSPACE_RGB,
>                                FALSE,
>                                8,
>                                600,
>                                900 );
>
>
>        poppler_page_render_to_pixbuf ( page,
>                                        0,
>                                        0,
>                                        600,
>                                        900,
>                                        1,
>                                        0,
>                                        pixBuf);
>
>   GtkWidget *window;
>
>   gtk_init (&argc, &argv);
>
>   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>   gtk_widget_show  (window);
>
>   gtk_main ();
>
>   return 0;
>
>
> }
>
>
>
>
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
>



-- 
Counting bodies like sheep to the rhythm of the war drums.


More information about the poppler mailing list