Skip Menu |

This queue is for tickets about the Gtk2-MozEmbed CPAN distribution.

Report information
The Basics
Id: 24035
Status: resolved
Priority: 0/
Queue: Gtk2-MozEmbed

People
Owner: Nobody in particular
Requestors: slanning [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.04
  • 0.05
  • 0.06
Fixed in: (no value)



Subject: segmentation fault
A minimal example shows a segfault: #!/usr/bin/perl use strict; use warnings; use Glib qw(TRUE FALSE); use Gtk2 -init; use Gtk2::MozEmbed; my $window = Gtk2::Window -> new(); my $moz = Gtk2::MozEmbed -> new(); $window -> add($moz); $window -> show_all(); Gtk2 -> main; __END__ Taking out the `add($moz)', it won't segfault. $ pkg-config --modversion firefox-gtkmozembed 1.5.0.8 perl 5.8.7 latest Gtk2, Glib, ExtUtils::*
Yeah, I can reproduce the problem. Unfortunately, I have no idea why it's happening. Nothing in Gtk2::MozEmbed and pumzilla changed. Gtk2::MozEmbed is really just a very thin wrapper around libgtkmozembed. So my guess is that something is wrong with the libgtkmozembed from Firefox 2.0.
On Thu Dec 28 12:59:03 2006, TSCH wrote: Show quoted text
> So my guess is that something is wrong with the libgtkmozembed from > Firefox 2.0.
Oh, you actually seem to be running Firefox 1.5.x. So it looks like libgtkmozembed broke even earlier.
I think it's from at least the previous version, 1.5.0.7, because I waited a couple months before filing the bug report. (For reference: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061115 Ubuntu/dapper-security Firefox/1.5.0.8 ) I'll try to reproduce it outside of Gtk2-Perl.
The attached C++ file also segfaults, apparently on `gtk_moz_embed_new'... Running it in `gdb`, I got this: ------8<-------------------- (gdb) run Starting program: /home/slanning/mozilla/moztest [Thread debugging using libthread_db enabled] [New Thread -1221404992 (LWP 5994)] Setting up component path. Setting up profile. Getting browser. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1221404992 (LWP 5994)] 0xb74bd2ca in g_type_check_class_cast () from /usr/lib/libgobject-2.0.so.0 (gdb) bt #0 0xb74bd2ca in g_type_check_class_cast () from /usr/lib/libgobject-2.0.so.0 #1 0xb7c45df8 in gtk_moz_embed_class_init (klass=0x8072238) at gtkmozembed2.cpp:283 #2 0xb7eb04f0 in gtk_type_is_a () from /usr/lib/libgtk-1.2.so.0 #3 0xb7eb0799 in gtk_type_class () from /usr/lib/libgtk-1.2.so.0 #4 0xb7eb09ea in gtk_type_new () from /usr/lib/libgtk-1.2.so.0 #5 0xb7c467df in gtk_moz_embed_new () at gtkmozembed2.cpp:534 #6 0x08048a95 in main () ------>8-------------------- Not sure if anything grabs your attention there. (libgtk-1.2 ?)
/* Note: this was just copied/modified from a post that I googled from a mailing list or newsgroup. I don't remember who wrote it. */ /* g++ \ `gtk-config --libs --cflags` `glib-config --libs --cflags` \ `pkg-config firefox-gtkmozembed --libs --cflags` \ test-gtkmozembed.cpp -o moztest && ./moztest */ #include <gtk/gtk.h> #include "gtkmozembed.h" #include "mozilla-config.h" #include <stdio.h> int main(int argc, char * argv[]) { GtkWidget * window; GtkWidget * browser; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); printf("Setting up component path.\n"); fflush(stdout); gtk_moz_embed_set_comp_path("/usr/lib/mozilla-firefox"); printf("Setting up profile.\n"); fflush(stdout); gtk_moz_embed_set_profile_path("/tmp/.mozilla", "firefox"); printf("Getting browser.\n"); fflush(stdout); browser = gtk_moz_embed_new(); printf("Checking browser.\n"); fflush(stdout); if(!browser) { printf("Browser is null.\n"); fflush(stdout); } gtk_container_add(GTK_CONTAINER(window), browser); gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser), "http://www.google.com/"); printf("Here.\n"); fflush(stdout); gtk_widget_show(window); gtk_main(); return 0; }
I think I see what the problem is now, though I haven't tested it yet. I got it compiling with: g++ `pkg-config --libs --cflags gtk+-x11-2.0` `pkg-config --libs --cflags glib-2.0` `pkg-config firefox-gtkmozembed --libs --cflags` test-gtkmozembed.cpp -o moztest That is, I replaced the "1.2" gtk-config and glib-config by versions which work with "2.0". It doesn't segfault now, at least. (I also removed gtk-1.2, though, so I have to make sure it still works after reinstalling, and so on.)
Yeah, I can reproduce it now. Here are two implementations of what should be the same program. One in C, one in Perl. The C version works, the Perl version segfaults when show() is called on the gtkmozembed object (or show_all() on the window). Here's the backtrace: #0 0xb7245037 in EmbedPrivate::Realize (this=0x83cf830, aAlreadyRealized=0xbfa6ca68) at EmbedPrivate.cpp:280 #1 0xb724390b in gtk_moz_embed_realize (widget=0x83ba0f8) at gtkmozembed2.cpp:606 #2 0xb7d7e869 in IA__g_cclosure_marshal_VOID__VOID (closure=0x81ebc80, return_value=0x0, n_param_values=1, param_values=0xbfa6cd1c, invocation_hint=0xbfa6cbfc, marshal_data=0xb72437c0) at gmarshal.c:77 #3 0xb7d6f709 in g_type_class_meta_marshal (closure=0x81ebc80, return_value=0x0, n_param_values=1, param_values=0xbfa6cd1c, invocation_hint=0xbfa6cbfc, marshal_data=0x74) at gclosure.c:567 #4 0xb7d70eeb in IA__g_closure_invoke (closure=0x81ebc80, return_value=0x0, n_param_values=1, param_values=0xbfa6cd1c, invocation_hint=0xbfa6cbfc) at gclosure.c:490 #5 0xb7d82b9a in signal_emit_unlocked_R (node=0x83bfb30, detail=0, instance=0x83ba0f8, emission_return=0x0, instance_and_params=0xbfa6cd1c) at gsignal.c:2370 #6 0xb7d83b73 in IA__g_signal_emit_valist (instance=0x83ba0f8, signal_id=12, detail=0, var_args=0x1 <Address 0x1 out of bounds>) at gsignal.c:2199 #7 0xb7d83e19 in IA__g_signal_emit (instance=0x83ba0f8, signal_id=12, detail=0) at gsignal.c:2243 #8 0xb7628abc in IA__gtk_widget_realize (widget=0x83ba0f8) at gtkwidget.c:2550 #9 0xb7628ecf in IA__gtk_widget_map (widget=0x83ba0f8) at gtkwidget.c:2467 #10 0xb763aa25 in gtk_window_map (widget=0x83c6000) at gtkwindow.c:4101 #11 0xb7d7e869 in IA__g_cclosure_marshal_VOID__VOID (closure=0x83bfb78, return_value=0x0, n_param_values=1, param_values=0xbfa6d26c, invocation_hint=0xbfa6d14c, marshal_data=0xb763a840) at gmarshal.c:77 #12 0xb7d6f709 in g_type_class_meta_marshal (closure=0x83bfb78, return_value=0x0, n_param_values=1, param_values=0xbfa6d26c, invocation_hint=0xbfa6d14c, marshal_data=0x6c) at gclosure.c:567 #13 0xb7d70eeb in IA__g_closure_invoke (closure=0x83bfb78, return_value=0x0, n_param_values=1, param_values=0xbfa6d26c, invocation_hint=0xbfa6d14c) at gclosure.c:490 #14 0xb7d82b9a in signal_emit_unlocked_R (node=0x83bfba0, detail=0, instance=0x83c6000, emission_return=0x0, instance_and_params=0xbfa6d26c) at gsignal.c:2370 #15 0xb7d83b73 in IA__g_signal_emit_valist (instance=0x83c6000, signal_id=10, detail=0, var_args=0xb7d1b004 "\205À\017\224À\203Ä\024[\017¶À]Ã", '\220' <repeats 14 times>, "U\211åWVSèÜDüÿ\201ÃáÅ\004") at gsignal.c:2199 #16 0xb7d83e19 in IA__g_signal_emit (instance=0x83c6000, signal_id=10, detail=0) at gsignal.c:2243 #17 0xb7628e93 in IA__gtk_widget_map (widget=0x83c6000) at gtkwidget.c:2469 #18 0xb763ab85 in gtk_window_show (widget=0x83c6000) at gtkwindow.c:4066 #19 0xb7d7e869 in IA__g_cclosure_marshal_VOID__VOID (closure=0x8199b88, return_value=0x0, n_param_values=1, param_values=0xbfa6d7fc, invocation_hint=0xbfa6d6dc, marshal_data=0xb763aa40) at gmarshal.c:77 #20 0xb7d6f709 in g_type_class_meta_marshal (closure=0x8199b88, return_value=0x0, n_param_values=1, param_values=0xbfa6d7fc, invocation_hint=0xbfa6d6dc, marshal_data=0x5c) at gclosure.c:567 #21 0xb7d70eeb in IA__g_closure_invoke (closure=0x8199b88, return_value=0x0, n_param_values=1, param_values=0xbfa6d7fc, invocation_hint=0xbfa6d6dc) at gclosure.c:490 #22 0xb7d82b9a in signal_emit_unlocked_R (node=0x83bfa90, detail=0, instance=0x83c6000, emission_return=0x0, instance_and_params=0xbfa6d7fc) at gsignal.c:2370 #23 0xb7d83b73 in IA__g_signal_emit_valist (instance=0x83c6000, signal_id=8, detail=0, var_args=0x800003a <Address 0x800003a out of bounds>) at gsignal.c:2199 #24 0xb7d83e19 in IA__g_signal_emit (instance=0x83c6000, signal_id=8, detail=0) at gsignal.c:2243 #25 0xb7629888 in IA__gtk_widget_show (widget=0x83c6000) at gtkwidget.c:2276 #26 0xb744c4e0 in gtk_container_show_all (widget=0x83c6000) at gtkcontainer.c:2321 #27 0xb762950e in IA__gtk_widget_show_all (widget=0x83c6000) at gtkwidget.c:2424 #28 0xb793afbd in XS_Gtk2__Widget_destroy (my_perl=0x8148008, cv=0x83313f8) at GtkWidget.xs:495 #29 0x080bc821 in Perl_pp_entersub () #30 0x080bb273 in Perl_runops_standard () #31 0x080639b4 in perl_run () #32 0x08060012 in main () (If you wonder about XS_Gtk2__Widget_destroy appearing in there, that's because gtk_widget_destroy, _show, _show_all, and a few other methods are implemented as aliases of the same xsub.) Here's the code around line 280 of EmbedPrivate.cpp: // save the window id of the newly created window nsCOMPtr<nsIWidget> mozWidget; mWindow->mBaseWindow->GetMainWidget(getter_AddRefs(mozWidget)); // get the native drawing area GdkWindow *tmp_window = NS_STATIC_CAST(GdkWindow *, mozWidget->GetNativeData(NS_NATIVE_WINDOW)); It looks like, when running the Perl version, GetMainWidget doesn't set mozWidget: (gdb) print mozWidget $1 = {<nsCOMPtr_base> = {mRawPtr = 0x0}, <No data fields>} So we get a segfault when we try to call GetNativeData on it. When I set a breakpoint at this location when running the C version, this doesn't happen: (gdb) print mozWidget $1 = {<nsCOMPtr_base> = {mRawPtr = 0x8270d00}, <No data fields>} Any ideas?
#include <gtk/gtk.h> #include <gtkmozembed.h> /** * Compile with * gcc `pkg-config --libs --cflags gtk+-2.0 firefox-gtkmozembed` moz-test.c -o moz-test */ int main(int argc, char * argv[]) { GtkWidget * window; GtkWidget * browser; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); browser = gtk_moz_embed_new(); gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser), "http://www.google.com/"); gtk_container_add(GTK_CONTAINER(window), browser); gtk_widget_show_all(window); gtk_main(); return 0; }
#!/usr/bin/perl use strict; use warnings; use Gtk2::MozEmbed; Gtk2->init; my $window = Gtk2::Window->new; my $browser = Gtk2::MozEmbed->new; $browser->load_url ('www.google.com'); $window->add ($browser); $window->show_all; Gtk2->main;
From: SLANNING [...] cpan.org
The C one doesn't even work for me, hrmmm...
I just released 0.07 which prefers xulrunner-gtkmozembed over firefox-gtkmozembed or mozilla-gtkmozembed. The former solves the segfault issues for me. Please reopen if the bugs is still there for you.