After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732784 - Crashes when closing the 2nd window
Crashes when closing the 2nd window
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
3.12.x (obsolete)
Other All
: Normal critical
: ---
Assigned To: Michael Catanzaro
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-05 22:07 UTC by Bastien Nocera
Modified: 2014-08-10 08:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ephy-title-box: fix crash when closing second window (3.61 KB, patch)
2014-07-06 02:16 UTC, Michael Catanzaro
accepted-commit_now Details | Review
ephy-title-box: Fix a warning when closing window (2.33 KB, patch)
2014-07-06 07:14 UTC, Yosef Or Boczko
committed Details | Review
ephy-title-box: fix crash when closing second window (3.80 KB, patch)
2014-07-06 12:11 UTC, Michael Catanzaro
accepted-commit_now Details | Review
ephy-title-box: Fix crash when closing second window (3.80 KB, patch)
2014-07-06 12:27 UTC, Michael Catanzaro
committed Details | Review
Revert "ephy-title-box: Fix a type" (950 bytes, patch)
2014-07-21 15:46 UTC, Michael Catanzaro
committed Details | Review
Revert "ephy-title-box: Fix a warning when closing window" (2.28 KB, patch)
2014-07-21 15:46 UTC, Michael Catanzaro
committed Details | Review
Revert "ephy-title-box: Fix crash when closing second window" (3.62 KB, patch)
2014-07-21 15:46 UTC, Michael Catanzaro
committed Details | Review
ephy-title-box: Fix crash when closing second window (1.19 KB, patch)
2014-07-21 15:47 UTC, Michael Catanzaro
committed Details | Review

Description Bastien Nocera 2014-07-05 22:07:22 UTC
epiphany-3.12.1-2.fc21.x86_64

With 2 windows opened, I closed one of those and epiphany crashed:

  • #0 g_type_check_instance_is_fundamentally_a
    at gtype.c line 3978
  • #1 g_object_unref
    at gobject.c line 3026
  • #2 ephy_title_box_set_web_view
    at ephy-title-box.c line 553
  • #3 ephy_title_box_dispose
    at ephy-title-box.c line 386
  • #4 g_object_run_dispose
    at gobject.c line 1076
  • #5 gtk_header_bar_forall
  • #6 gtk_container_destroy
  • #10 <emit signal ??? on instance 0x1976440 [EphyToolbar]>
    at gsignal.c line 3367
  • #11 gtk_widget_dispose
  • #12 g_object_unref
    at gobject.c line 3092
  • #13 gtk_widget_unparent
  • #14 unset_titlebar
  • #15 gtk_window_dispose
  • #16 gtk_application_window_dispose
  • #17 g_object_run_dispose
    at gobject.c line 1076
  • #18 g_task_return_now
    at gtask.c line 1076
  • #19 g_task_return
    at gtask.c line 1129
  • #20 has_modified_forms_cb
    at ephy-web-view.c line 2379
  • #21 g_task_return_now
    at gtask.c line 1076
  • #22 g_task_return
    at gtask.c line 1129
  • #23 has_modified_forms_cb
    at ephy-web-extension-proxy.c line 230
  • #24 g_simple_async_result_complete
    at gsimpleasyncresult.c line 763
  • #25 reply_cb
    at gdbusproxy.c line 2623
  • #26 g_simple_async_result_complete
    at gsimpleasyncresult.c line 763
  • #27 g_dbus_connection_call_done
    at gdbusconnection.c line 5508
  • #28 g_simple_async_result_complete
    at gsimpleasyncresult.c line 763
  • #29 complete_in_idle_cb
    at gsimpleasyncresult.c line 775
  • #30 g_main_context_dispatch
    at gmain.c line 3064
  • #31 g_main_context_dispatch
    at gmain.c line 3663
  • #32 g_main_context_iterate
    at gmain.c line 3734
  • #33 g_main_context_iteration
    at gmain.c line 3795
  • #34 g_application_run
    at gapplication.c line 2115
  • #35 main
    at ephy-main.c line 488

Comment 1 Yosef Or Boczko 2014-07-05 22:13:59 UTC
It happen to me just when I try to close the 2nd window with accels (i.e. with Ctrl+W
I get crash, with the close button I didn't).

(epiphany:24460): GLib-GObject-WARNING **: gsignal.c:2579: instance '0xa7d950' has no handler with id '7035'

(epiphany:24460): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

Program received signal SIGSEGV, Segmentation fault.
g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0xbb6990, fundamental_type=fundamental_type@entry=80) at gtype.c:3977
3977	  return NODE_FUNDAMENTAL_TYPE(lookup_type_node_I (type_instance->g_class->g_type)) == fundamental_type;
(gdb) bt
  • #0 g_type_check_instance_is_fundamentally_a
    at gtype.c line 3977
  • #1 g_object_unref
    at gobject.c line 3067
  • #2 ephy_title_box_set_web_view
    at ephy-title-box.c line 526
  • #3 ephy_title_box_dispose
    at ephy-title-box.c line 358
  • #4 g_object_run_dispose
    at gobject.c line 1076
  • #5 gtk_header_bar_forall
    at gtkheaderbar.c line 1524
  • #6 gtk_container_destroy
    at gtkcontainer.c line 1413
  • #7 g_closure_invoke
    at gclosure.c line 768
  • #8 signal_emit_unlocked_R
    at gsignal.c line 3669
  • #9 g_signal_emit_valist
    at gsignal.c line 3309
  • #10 g_signal_emit
    at gsignal.c line 3365
  • #11 gtk_widget_dispose
    at gtkwidget.c line 11944
  • #12 g_object_unref
    at gobject.c line 3133
  • #13 gtk_widget_unparent
    at gtkwidget.c line 4756
  • #14 unset_titlebar
    at gtkwindow.c line 3723
  • #15 gtk_window_dispose
    at gtkwindow.c line 2805
  • #16 gtk_application_window_dispose
    at gtkapplicationwindow.c line 775
  • #17 g_object_run_dispose
    at gobject.c line 1076
  • #18 g_task_return_now
    at gtask.c line 1076
  • #19 complete_in_idle_cb
    at gtask.c line 1085
  • #20 g_main_dispatch
    at gmain.c line 3064
  • #21 g_main_context_dispatch
    at gmain.c line 3663
  • #22 g_main_context_iterate
    at gmain.c line 3734
  • #23 g_main_context_iteration
    at gmain.c line 3795
  • #24 g_application_run
    at gapplication.c line 2115
  • #25 main
    at ephy-main.c line 488




I think the warning isn't new, just the crash it new (since some changes in glib from git master).
It hard to me to understand where the leak, but it look like this is a leak in EphyTitleBox, but I
not sure.
Comment 2 Michael Catanzaro 2014-07-06 02:16:30 UTC
Created attachment 279974 [details] [review]
ephy-title-box: fix crash when closing second window

These binding could already have been destroyed. It might be safe to
simply remove the calls to g_clear_object, since they are not needed for
memory management, but then the bindings might not be unbound if a new
web view is set before the old one is destroyed.

This patch may be unnecessarily verbose, since when I simply removed the calls to g_clear_object I did not notice any regressions.
Comment 3 Yosef Or Boczko 2014-07-06 07:07:00 UTC
Review of attachment 279974 [details] [review]:

Looks good to me.
I make more patch to fix more a warning there.

::: src/ephy-title-box.c
@@ +518,3 @@
 
+static void
+title_binding_destroyed_cb (gpointer data)

Please, added the ephy_title_box_ prefix before, as in the
rest of the code in this file.

@@ +531,3 @@
+
+static void
+uri_binding_destroyed_cb (gpointer data)

Ditto.

@@ +600,3 @@
+                                                     G_BINDING_SYNC_CREATE,
+                                                     NULL, NULL,
+                                                     title_box, title_binding_destroyed_cb);

Ditto.

@@ +606,3 @@
                                                    G_BINDING_SYNC_CREATE,
+                                                   ephy_title_box_transform_uri_to_label, NULL,
+                                                   title_box, uri_binding_destroyed_cb);

Ditto.
Comment 4 Yosef Or Boczko 2014-07-06 07:09:38 UTC
Review of attachment 279974 [details] [review]:

Sorry, I forgot more a trivial comment.

::: src/ephy-title-box.c
@@ +525,3 @@
+  title_box = EPHY_TITLE_BOX (data);
+  priv = ephy_title_box_get_instance_private (title_box);
+

Added here a log messgae (without the ephy_title_box_ prefix):
LOG ("title_binding_destroyed_cb title-box %p", title_box);

@@ +538,3 @@
+  title_box = EPHY_TITLE_BOX (data);
+  priv = ephy_title_box_get_instance_private (title_box);
+

Same here:
LOG ("uri_binding_destroyed_cb title-box %p", title_box);
Comment 5 Yosef Or Boczko 2014-07-06 07:14:25 UTC
Created attachment 279977 [details] [review]
ephy-title-box: Fix a warning when closing window

I'm not sure if my patch is right, so please look into it :-)
Comment 6 Yosef Or Boczko 2014-07-06 07:17:58 UTC
My patch above needs to fix this warning:
(epiphany:9702): GLib-GObject-WARNING **: gsignal.c:2579: instance '0xca8170' has no handler with id '1732'
Comment 7 Michael Catanzaro 2014-07-06 12:11:22 UTC
Created attachment 279985 [details] [review]
ephy-title-box: fix crash when closing second window

These binding could already have been destroyed. It might be safe to
simply remove the calls to g_clear_object, since they are not needed for
memory management, but then the bindings might not be unbound if a new
web view is set before the old one is destroyed.
Comment 8 Yosef Or Boczko 2014-07-06 12:15:09 UTC
Review of attachment 279985 [details] [review]:

It ok the fact I reviewing patches in epiphany's bugs?

(please, make the first word in the title to title case i.e. fix -> Fix)
Comment 9 Michael Catanzaro 2014-07-06 12:26:13 UTC
Review of attachment 279977 [details] [review]:

Looks good to me; I'm not sure why the handler is being disconnected early, but this is cleaner anyway.
Comment 10 Michael Catanzaro 2014-07-06 12:27:48 UTC
Created attachment 279986 [details] [review]
ephy-title-box: Fix crash when closing second window
Comment 11 Michael Catanzaro 2014-07-06 12:32:32 UTC
(In reply to comment #8)
> Review of attachment 279985 [details] [review]:
> 
> It ok the fact I reviewing patches in epiphany's bugs?

I dunno, but since you wrote this file I'm not too worried.
Comment 12 Yosef Or Boczko 2014-07-06 14:02:09 UTC
Review of attachment 279986 [details] [review]:

Pushed as 005ce53 - ephy-title-box: Fix crash when closing second window
Comment 13 Yosef Or Boczko 2014-07-06 14:02:40 UTC
Review of attachment 279977 [details] [review]:

Pushed as 7eabfe4 - ephy-title-box: Fix a warning when closing window
Comment 14 Yosef Or Boczko 2014-07-06 14:03:54 UTC
Pushed to master and gnome-3-12.
Comment 15 Carlos Garcia Campos 2014-07-08 08:08:50 UTC
(In reply to comment #8)
> Review of attachment 279985 [details] [review]:
> 
> It ok the fact I reviewing patches in epiphany's bugs?

No, we have maintainers for that. Patches are indeed wrong.
 
> (please, make the first word in the title to title case i.e. fix -> Fix)

Patches here workaround the problem, instead of fixing. When you start a commit message with "For some reason" is because you haven't investigated enough the problem :-)

The real problem is that the web view is destroyed and nobody has called ephy_title_box_set_web_view() with NULL before, so when it's called with a new web view, the old web view is already destroyed, but the pointer hasn't been invalidated. That's why you get warnings about signals not present in the object, a warning also when trying to unref the view, and the bindings are already disconnected, because g_binding uses weak references. 
So, the EphyWindow should call ephy_title_box_set_web_view() with NULL when it's destroyed, but in ephy_window_dispose it's too late, because the children have already been destroyed at that point. I think EphyTitleBox should not take a reference to the view, and use a weak reference instead.
Comment 16 Michael Catanzaro 2014-07-09 15:46:14 UTC
Yosef, I know you're working on this; I'm just assigning this to myself since my patch was pushed and I don't want to lose track of it.
Comment 17 Michael Catanzaro 2014-07-21 15:46:48 UTC
Created attachment 281319 [details] [review]
Revert "ephy-title-box: Fix a type"

This reverts commit 5c8005ec5adb1b9432d3390e73de5213899502cb.
Comment 18 Michael Catanzaro 2014-07-21 15:46:52 UTC
Created attachment 281320 [details] [review]
Revert "ephy-title-box: Fix a warning when closing window"

This reverts commit 7eabfe44e9804717bfb6f0fa10e53f9c4d170e38.
Comment 19 Michael Catanzaro 2014-07-21 15:46:56 UTC
Created attachment 281321 [details] [review]
Revert "ephy-title-box: Fix crash when closing second window"

This reverts commit 005ce536fd94db9fca3906a358ca555a3e557771.
Comment 20 Michael Catanzaro 2014-07-21 15:47:00 UTC
Created attachment 281322 [details] [review]
ephy-title-box: Fix crash when closing second window

The web view can be destroyed out from under us, so we need to use a
weak reference to determine if it is still alive.
Comment 21 Yosef Or Boczko 2014-07-21 19:59:17 UTC
Michael, I think we not must to revert the patches, they just do some
unrelated cleanup, but it still cleanup.
Comment 22 Michael Catanzaro 2014-07-21 22:02:39 UTC
My patch should be reverted since it's unnecessary and messy compared to using a weak reference.  Your middle patch "Fix a warning when closing window" indeed does not need to be reverted, I just think it's nicer to store the signal ID.
Comment 23 Michael Catanzaro 2014-08-09 21:01:48 UTC
Carlos, ping :)
Comment 24 Carlos Garcia Campos 2014-08-10 08:05:59 UTC
Pushed all patches, thanks you!