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 778839 - todo.txt: gnome-todo segfaults when changing list color
todo.txt: gnome-todo segfaults when changing list color
Status: RESOLVED FIXED
Product: gnome-todo
Classification: Other
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME To Do maintainer(s)
GNOME To Do maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-02-17 15:23 UTC by Mohammed Sadiq
Modified: 2017-03-28 02:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object (1.73 KB, patch)
2017-03-17 14:44 UTC, Rohit Kaushik
none Details | Review
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object (2.00 KB, patch)
2017-03-22 17:57 UTC, Rohit Kaushik
none Details | Review
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object (2.02 KB, patch)
2017-03-22 18:03 UTC, Rohit Kaushik
needs-work Details | Review
list-selector-grid-item: :Don't Call update_thumbnail if list has been destroyed (2.32 KB, patch)
2017-03-23 12:57 UTC, Rohit Kaushik
none Details | Review
list-selector-grid-item don't update thumbnail on dispose (2.26 KB, patch)
2017-03-28 01:59 UTC, Georges Basile Stavracas Neto
committed Details | Review

Description Mohammed Sadiq 2017-02-17 15:23:02 UTC
How to reproduce:

1. Create a new list with todo.txt provider
2. Open the list -> Click color chooser -> select some color

Result:

gnome-todo segfaults logging the following to terminal window:

** (gnome-todo:4675): CRITICAL **: gtd_task_list_get_color: assertion 'GTD_IS_TASK_LIST (list)' failed

** (gnome-todo:4675): CRITICAL **: gtd_task_list_get_tasks: assertion 'GTD_IS_TASK_LIST (list)' failed

Thread 1 "gnome-todo" received signal SIGSEGV, Segmentation fault.
0x000055555556f5f5 in gtd_list_selector_grid_item__render_thumbnail (
    item=0x5555564416b0)
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/views/gtd-list-selector-grid-item.c:125
125	  if (LUMINANCE (color) < 0.5)
(gdb) thread apply all bt fu
func_and         funcs            futimens         future
func_not         funlockfile      futimes          
func_or          funlockfile@plt  futimesat        
(gdb) thread apply all bt full

Thread 1 (Thread 0x7ffff7f09a80 (LWP 4675))

  • #0 gtd_list_selector_grid_item__render_thumbnail
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/views/gtd-list-selector-grid-item.c line 125
  • #1 gtd_list_selector_grid_item__update_thumbnail
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/views/gtd-list-selector-grid-item.c line 281
  • #2 gtd_list_selector_grid_item_state_flags_changed
  • #3 g_cclosure_marshal_VOID__FLAGSv
    at /home/sadiq/jhbuild/checkout/glib/gobject/gmarshal.c line 1570
  • #4 _g_closure_invoke_va
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 867
  • #5 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3300
  • #6 g_signal_emit
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3447
  • #7 gtk_widget_propagate_state
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkwidget.c line 12828
  • #8 gtk_widget_update_state_flags
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkwidget.c line 8784
  • #9 gtk_widget_unset_state_flags
  • #10 gtk_widget_unparent
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkwidget.c line 4647
  • #11 gtk_flow_box_remove
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkflowbox.c line 3254
  • #12 g_cclosure_marshal_VOID__OBJECTv
  • #13 _g_closure_invoke_va
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 867
  • #14 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3300
  • #15 g_signal_emit
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3447
  • #16 gtk_container_remove
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkcontainer.c line 1905
  • #17 gtk_widget_dispose
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkwidget.c line 12051
  • #18 gtd_list_selector_grid_item_dispose
  • #19 g_object_run_dispose
    at /home/sadiq/jhbuild/checkout/glib/gobject/gobject.c line 1084
  • #20 gtk_widget_destroy
    at /home/sadiq/jhbuild/checkout/gtk+-3/gtk/gtkwidget.c line 4720
  • #21 gtd_list_selector_grid_list_removed
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/views/gtd-list-selector-grid.c line 85
  • #22 g_closure_invoke
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 804
  • #23 signal_emit_unlocked_R
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3635
  • #24 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3391
  • #25 g_signal_emit
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3447
  • #26 gtd_manager__list_removed
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/engine/gtd-manager.c line 452
  • #27 gtd_manager__provider_removed
  • #28 g_cclosure_marshal_VOID__POINTERv
    at /home/sadiq/jhbuild/checkout/glib/gobject/gmarshal.c line 2026
  • #29 _g_closure_invoke_va
  • #30 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3300
  • #31 g_signal_emit_by_name
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3487
  • #32 on_provider_removed
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/engine/gtd-plugin-manager.c line 170
  • #33 g_closure_invoke
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 804
  • #34 signal_emit_unlocked_R
  • #35 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3391
  • #36 g_signal_emit_by_name
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3487
  • #37 gtd_plugin_todo_txt_monitor_source
    at /home/sadiq/jhbuild/checkout/gnome-todo/plugins/todo-txt/gtd-plugin-todo-txt.c line 81
  • #38 ffi_call_unix64
    from /usr/lib/x86_64-linux-gnu/libffi.so.6
  • #39 ffi_call
    from /usr/lib/x86_64-linux-gnu/libffi.so.6
  • #40 g_cclosure_marshal_generic_va
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 1604
  • #41 _g_closure_invoke_va
    at /home/sadiq/jhbuild/checkout/glib/gobject/gclosure.c line 867
  • #42 g_signal_emit_valist
    at /home/sadiq/jhbuild/checkout/glib/gobject/gsignal.c line 3300
  • #43 g_signal_emit
  • #44 g_file_monitor_emit_event
    at /home/sadiq/jhbuild/checkout/glib/gio/gfilemonitor.c line 290
  • #45 g_file_monitor_source_dispatch
    at /home/sadiq/jhbuild/checkout/glib/gio/glocalfilemonitor.c line 546
  • #46 g_main_dispatch
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3203
  • #47 g_main_context_dispatch
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3856
  • #48 g_main_context_iterate
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3929
  • #49 g_main_context_iteration
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3990
  • #50 g_application_run
    at /home/sadiq/jhbuild/checkout/glib/gio/gapplication.c line 2381
  • #51 main
    at /home/sadiq/jhbuild/checkout/gnome-todo/src/main.c line 41

Thanks
Comment 1 Rohit Kaushik 2017-03-17 14:44:55 UTC
Created attachment 348182 [details] [review]
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object

Current gtd_list_selector_grid_item__update_thumbnail is being called inside
gtd_list_selector_grid_item_state_flags_changed which is also called if widget
is being disposed. So we check if dispose has been called earlier by checking if item
has a list reference and call update thumbnail only if item->list is present.Otherwise,
this causes segmentation fault at some places like updating list color, deletion
of todo.tx file by user while todo is running etc.
Comment 2 Georges Basile Stavracas Neto 2017-03-22 14:50:22 UTC
Review of attachment 348182 [details] [review]:

Only a minor nitpick.

::: src/views/gtd-list-selector-grid-item.c
@@ +376,3 @@
     GTK_WIDGET_CLASS (gtd_list_selector_grid_item_parent_class)->state_flags_changed (item, flags);
 
+  if(self->list)

You should write a comment explaining when self->list is NULL.

Nitpick: space between 'if' and '('
Comment 3 Rohit Kaushik 2017-03-22 17:57:33 UTC
Created attachment 348522 [details] [review]
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object

Current gtd_list_selector_grid_item__update_thumbnail is being
called inside gtd_list_selector_grid_item_state_flags_changed
which is also called if widget is being disposed. So we check
if dispose has been called earlier by checking if item
has a list reference and call update thumbnail only if item->list
is present.Otherwise,this causes segmentation fault at some places
like updating list color, deletion of todo.tx file by user while
todo is running etc.
Comment 4 Rohit Kaushik 2017-03-22 18:03:28 UTC
Created attachment 348523 [details] [review]
list_selector_grid_item: Call update_thumbnail only if grid_item has valid list object

Currently gtd_list_selector_grid_item__update_thumbnail is being
called inside gtd_list_selector_grid_item_state_flags_changed
which is also called if widget is being disposed. So we check
if dispose has been called earlier by checking if
list_selector_grid_item has a list reference and call
update thumbnail only if item->list is present.Otherwise,
this causes segmentation fault at some places like
updating list color, deletion of todo.txt file by user while
todo is running etc.
Comment 5 Georges Basile Stavracas Neto 2017-03-23 01:07:10 UTC
Review of attachment 348523 [details] [review]:

The commit message needs improvement. A few comments:

 - The module name doesn't use '_', but '-', without the gtd- prefix. So, 'selector-grid-item'
 - The title isn't very informative. In 10 words, what does the patch do?
 - The body also needs improvement. Good commit messages have 3 paragraphs: context, problem and fixup. Please reorganize the message like that.

I know it's nitpicking, but good commit messages make a huge difference.
Comment 6 Rohit Kaushik 2017-03-23 12:57:47 UTC
Created attachment 348571 [details] [review]
list-selector-grid-item: :Don't Call update_thumbnail if list has been destroyed

Rendering of list_selector_grid_item with null list reference causes
segmentation fault errors. While updating thumbnail of grid_item,
check is not imposed if list has been disposed.

The problem is that grid_item_update_thumbnail is being called even if
the list reference has been disposed.When provider is removed all the list
that it stores gets deleted.after disposal of item->list, grid item widget
flags changes which call the update_thumbnail which calls render_thumbnail.
This should only be called if list has not been disposed as thumbnail will
only be updated for non null list items in the grid.

The fix is to check if the gtd-list-selector-item has a reference to valid
list and if true call the gtd_list_selector_grid_item__update_thumbnail
else donot call the update_thumbnail.
Comment 7 Georges Basile Stavracas Neto 2017-03-28 01:50:14 UTC
Review of attachment 348571 [details] [review]:

LGTM (although the commit message still has some issues)
Comment 8 Georges Basile Stavracas Neto 2017-03-28 01:59:38 UTC
Created attachment 348851 [details] [review]
list-selector-grid-item don't update thumbnail on dispose

(Reattaching the patch with corrected commit message and comment)

Rendering of list_selector_grid_item with NULL list reference causes
segmentation fault errors. While updating thumbnail of grid_item,
check is not imposed if list has been disposed.

The problem is that grid_item_update_thumbnail is being called even if
the list reference has been disposed.When provider is removed all the
list that it stores gets deleted.after disposal of item->list, grid item
widget flags changes which call the update_thumbnail which calls
render_thumbnail. This should only be called if list has not been
disposed as thumbnail will only be updated for non null list items in
the grid.

The fix is to check if the gtd-list-selector-item has a reference to valid
list and if true call the gtd_list_selector_grid_item__update_thumbnail
else do not call the update_thumbnail.
Comment 9 Georges Basile Stavracas Neto 2017-03-28 02:01:20 UTC
Thanks for the patch!

Attachment 348851 [details] pushed as 63bffd1 - list-selector-grid-item don't update thumbnail on dispose