Mixing XS with Gtk2::TreeStore



Hi,

I have a perl program that displays a tree with a lot of nodes
(18_000) using Gtk2::TreeView and Gtk2::TreeStore. Populating the tree
store takes close to 2 seconds, which I find slow. I want to improve
the speed of the application by rewriting the slow part in XS.

So I rewrote the code used to fill the tree in a sample C file and it
works fine. But if I wrap that same C code through XS I get
segmentation fault each time that I try to store data into the
Gtk2::TreeStore. In my case both the tree view and the tree store are
created from Perl and manipulated through XS.

If I run the perl interpreter through a debugger I can see that the
segmentation fault occurs when I call
gtk_tree_store_insert_with_values(). What's more strange is that the
stack trace shows me that GTK ends up calling Perl and Gtk2 (the perl
library) functions even though the tree store is empty. Is it possible
to populate a Perl Gtk2::TreeStore from XS? Perhaps I should be adding
Perl data types to the tree store?

Here's the stack trace produced by gdb, frame #7 is my XS function:

#0  0x080b8f53 in Perl_mg_get ()
#1  0x080da43f in Perl_sv_setsv_flags ()
#2  0x080dadd4 in Perl_newSVsv ()
#3  0xb7c69df7 in gperl_sv_copy () from /usr/lib/perl5/auto/Glib/Glib.so
#4  0xb7c09c12 in boxed_proxy_collect_value (value=0xbf82e9f8,
n_collect_values=1, collect_values=0xbf82e9b8, collect_flags=0)
    at /build/buildd/glib2.0-2.16.4/gobject/gboxed.c:317
#5  0xb72aad53 in gtk_tree_store_set_valist_internal
(tree_store=0x84214d8, iter=0xbf82eaa4, emit_signal=0xbf82ea54,
maybe_need_sort=0xbf82ea50,
    var_args=0xbf82ea88 "\001") at
/build/buildd/gtk+2.0-2.12.9/gtk/gtktreestore.c:948
#6  0xb72acee7 in IA__gtk_tree_store_insert_with_values
(tree_store=0x84214d8, iter=0xbf82eaa4, parent=0x0, position=0)
    at /build/buildd/gtk+2.0-2.12.9/gtk/gtktreestore.c:1441
#7  0xb7c46758 in my_populate_treeview (xargs=0xbf82eafc,
node=0x8612128, parent=0x0, pos=0) at xs/code.c:215
#8  0xb7c46575 in populate_treeview (treeview=0x859d120,
node=0x8603788, namespaces=0x85f8c6c) at xs/code.c:165
#9  0xb7c4382f in XS_Xacobeo__XS_populate_treeview (my_perl=0x8153008,
cv=0x8527418) at lib/Xacobeo/XS.c:92
#10 0x080c22d3 in Perl_pp_entersub ()
#11 0x080c0cab in Perl_runops_standard ()
#12 0x0806727b in perl_run ()
#13 0x08063792 in main ()

All help is welcome.

-- 
Emmanuel Rodriguez



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]