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 780549 - Crash when removing bookmark if URL has been modified
Crash when removing bookmark if URL has been modified
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Bookmarks
3.24.x (obsolete)
Other Linux
: High critical
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-25 21:57 UTC by Eddy Castillo
Modified: 2017-08-24 08:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bookmarks-popover: Don't snapshot URLs when creating new bookmark rows (9.04 KB, patch)
2017-08-23 20:26 UTC, Gabriel Ivașcu
committed Details | Review

Description Eddy Castillo 2017-03-25 21:57:09 UTC
After editing the URL of a bookmark and clicking the "remove" button, it still shows up in the popover. If the user tries to remove it again, the crash happens.

To reproduce:
1. Open the "Bookmark Properties" window of bookmark.
2. Edit the URL.
3. Click "Remove bookmark".
4. Notice the bookmark has not been removed in the popover.
5. Repeat steps 1 and 3. (Open properties and remove)

backtrace 
  • #0 __GI_raise
    at ../sysdeps/unix/sysv/linux/raise.c line 58
  • #1 __GI_abort
    at abort.c line 89
  • #2 g_assertion_message
  • #3 g_assertion_message_expr
  • #4 ephy_bookmarks_manager_remove_bookmark
    at bookmarks/ephy-bookmarks-manager.c line 372
  • #5 ephy_bookmarks_properties_grid_actions_remove_bookmark
    at bookmarks/ephy-bookmark-properties-grid.c line 259
  • #6 g_closure_invoke
  • #7 signal_emit_unlocked_R
  • #8 g_signal_emit_valist
  • #9 g_signal_emit
  • #10 g_simple_action_activate
  • #11 gtk_action_muxer_activate_action
  • #12 gtk_action_muxer_activate_action
  • #13 gtk_real_button_clicked
  • #14 _g_closure_invoke_va
  • #15 g_signal_emit_valist
  • #16 g_signal_emit
  • #17 gtk_button_do_release
  • #18 gtk_real_button_released
  • #19 _g_closure_invoke_va
  • #20 g_signal_emit_valist
  • #21 g_signal_emit
  • #22 multipress_released_cb
  • #23 ffi_call_unix64
  • #24 ffi_call
  • #25 g_cclosure_marshal_generic_va
  • #26 _g_closure_invoke_va
  • #27 g_signal_emit_valist
  • #28 g_signal_emit
  • #29 gtk_gesture_multi_press_end
  • #30 g_cclosure_marshal_VOID__BOXEDv
  • #31 _g_closure_invoke_va
  • #32 g_signal_emit_valist
  • #33 g_signal_emit
  • #34 _gtk_gesture_check_recognized
  • #35 gtk_gesture_handle_event
  • #36 gtk_gesture_single_handle_event
  • #37 gtk_event_controller_handle_event
  • #38 _gtk_widget_run_controllers
  • #39 _gtk_marshal_BOOLEAN__BOXEDv
  • #40 _g_closure_invoke_va
  • #41 g_signal_emit_valist
  • #42 g_signal_emit
  • #43 gtk_widget_event_internal
  • #44 propagate_event
  • #45 gtk_main_do_event
  • #46 _gdk_event_emit
  • #47 gdk_event_source_dispatch
  • #48 g_main_context_dispatch
  • #49 g_main_context_iterate.isra
  • #50 g_main_context_iteration
  • #51 g_application_run
  • #52 main
    at ephy-main.c line 432

Comment 1 Gabriel Ivașcu 2017-03-26 20:23:02 UTC
I can't reproduce this, but it seems that the crash is actually a failed assertion in ephy_bookmarks_manager_remove_bookmark().

I think it's not wise to crash when you don't find the bookmark to remove, especially when it's being searched by its URL (which can be edited). Supposing we don't want to get rid of the assertion, it would make more sense to search the bookmark by ID, because that cannot be edited. Otherwise, just return from the remove function if the bookmark is not found.
Comment 2 Michael Catanzaro 2017-03-26 22:09:13 UTC
(In reply to Gabriel Ivașcu from comment #1)
> I think it's not wise to crash when you don't find the bookmark to remove,
> especially when it's being searched by its URL (which can be edited).

I'm not sure. Trying to remove a bookmark that's not there is API misuse. We probably do want to crash in that case!

I also was not able to reproduce the crash, but by following Eddy's steps I got some obviously-wrong behavior where the bookmark became duplicated instead. Also, the star in the location entry remained active, but it should have become inactive after the URL was edited to something else. This entire popover is really fragile I'm afraid; you can see I have dozens of commits to it trying to tighten up corner cases, but seems I missed a spot. :/
Comment 3 Eddy Castillo 2017-03-26 23:51:16 UTC
Apparently I missed a detail. The bookmark still shows up **only** in the tags section after the first removal. I omitted it without noticing, sorry.

4. Open the bookmarks popover, switch to the "tags" section and repeat removal.
Comment 4 Gabriel Ivașcu 2017-08-23 19:11:31 UTC
(In reply to Eddy Castillo from comment #3)
> Apparently I missed a detail. The bookmark still shows up **only** in the
> tags section after the first removal. I omitted it without noticing, sorry.
> 
> 4. Open the bookmarks popover, switch to the "tags" section and repeat
> removal.

Alright, I was now able to reproduce the bug.

Apparently the problem lays in ephy-bookmarks-popover.c in create_bookmark_row(). This function creates a new EphyBookmarkRow object from a bookmark and stores a copy of the bookmark's URL and title into the row's table of associations with g_object_set_data_full(). The EphyBookmarkRow object is later attached to the tags list box. When a bookmark is deleted, the corresponding bookmark row is searched by the bookmark's URL in the tags list box in order to be deleted too. In your scenario, deleting a bookmark after editing its URL creates a mismatch between the actual bookmark's URL and the row's URL from the table of associations. Thus the EphyRowBookmark object is not found and not destroyed which also means that the bookmark object is not destroyed. Since the very same bookmark was previously removed from EphyBookmarksManager's sequence of bookmarks during the first delete, the second delete causes EphyBookmarksManager to delete a bookmark that doesn't exist from its point of view. This causes the failed assertion in the manager and therefore the crash.

I'll be back with a patch that fixes this.
Comment 5 Gabriel Ivașcu 2017-08-23 20:26:59 UTC
Created attachment 358269 [details] [review]
bookmarks-popover: Don't snapshot URLs when creating new bookmark rows
Comment 6 Michael Catanzaro 2017-08-23 21:53:31 UTC
Comment on attachment 358269 [details] [review]
bookmarks-popover: Don't snapshot URLs when creating new bookmark rows

For gnome-3-24 as well
Comment 7 Gabriel Ivașcu 2017-08-24 08:26:19 UTC
Attachment 358269 [details] pushed as b6ced3e - bookmarks-popover: Don't snapshot URLs when creating new bookmark rows