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?