GNOME Bugzilla – Bug 695965
[a11] memory leak in GtkTreeViewAccessible
Last modified: 2014-03-26 23:13:05 UTC
==29897== 974 (160 direct, 814 indirect) bytes in 1 blocks are definitely lost in loss record 11,318 of 11,645 ==29897== at 0x4A0887C: malloc (vg_replace_malloc.c:270) ==29897== by 0x7D8275E: g_malloc (gmem.c:159) ==29897== by 0x7D9B005: g_slice_alloc (gslice.c:1003) ==29897== by 0x7D9B045: g_slice_alloc0 (gslice.c:1029) ==29897== by 0x7D03864: g_type_create_instance (gtype.c:1892) ==29897== by 0x7CE9EE5: g_object_constructor (gobject.c:1855) ==29897== by 0x7CE96FD: g_object_newv (gobject.c:1719) ==29897== by 0x7CE9E76: g_object_new_valist (gobject.c:1836) ==29897== by 0x7CE9111: g_object_new (gobject.c:1551) ==29897== by 0x77B5141: gtk_renderer_cell_accessible_new (gtkrenderercellaccessible.c:120) ==29897== by 0x77C0AD8: create_cell (gtktreeviewaccessible.c:405) ==29897== by 0x77C3B27: _gtk_tree_view_accessible_add_state (gtktreeviewaccessible.c:1933) ==29897== by 0x771A1D2: gtk_tree_view_real_set_cursor (gtktreeview.c:13235) ==29897== by 0x771A5E3: gtk_tree_view_set_cursor_on_cell (gtktreeview.c:13360) ==29897== by 0x771A355: gtk_tree_view_set_cursor (gtktreeview.c:13305) ==29897== by 0x74FEC2A: gtk_entry_completion_insert_action (gtkentrycompletion.c:1310) ==29897== by 0x74FED6A: gtk_entry_completion_insert_action_text (gtkentrycompletion.c:1340) ==29897== by 0x44C292: add_completion_actions (ephy-location-controller.c:286) ==29897== by 0x44C578: ephy_location_controller_constructed (ephy-location-controller.c:373) ==29897== by 0x7CE9812: g_object_newv (gobject.c:1747)
*** Bug 722030 has been marked as a duplicate of this bug. ***
The code originally comes from gail: https://git.gnome.org/browse/gail/tree/gail/gailtreeview.c#n4224 Ref removed here: https://git.gnome.org/browse/gtk+/commit/?id=7a411eb6dd4dd0dedf28f3b5414561e765886369 Reverted here: https://git.gnome.org/browse/gtk+/commit/?id=4238cc4b7b966687271ddf2c4309ff6f7e807f60 The leak seems to come from: https://git.gnome.org/browse/gtk+/tree/gtk/a11y/gtktreeviewaccessible.c?id=d0787765bc222200c2a66cef90bf6248833f8b21#n385 https://git.gnome.org/browse/gtk+/tree/gtk/a11y/gtktreeviewaccessible.c?id=d0787765bc222200c2a66cef90bf6248833f8b21#n406
Ref comes from: https://git.gnome.org/browse/gtk+/commit/?id=da30c8253b1aff3add99d6190f337c5be0b9d76a
Created attachment 269870 [details] [review] Fix memory leak (revised) The GtkCellAccessible passed into cell_info_new() already has a reference count from when it was created, so calling g_object_ref() in cell_info_new() is unnecessary and causes a memory leak (bugs #695965 and #722030). However, some GtkCellAccessibles get added to an AtkRelation as children of another cell, and when the parent cell is finalized, g_object_unref() gets called on the child (see gtk_cell_accessible_object_finalize()). 7a411eb6 did not account for this and so caused a crash in the case of hierarchical trees. The fix is to remove the g_object_ref() from cell_info_new() as before but add a replacement g_object_ref() in create_cell() only when adding the cell to an AtkRelation.
And now gtk_cell_accessible_object_finalize() has been removed in commit fef14e0e87d2 (bug #726838). So I believe the original patch on #722030, which was reverted, should be reinstated.
The patch is included in git master, isn't it? Though I think talking about bug 722030 is quite useless now that the large refactoring of the refcounting happened. In fact, I think this bug should be closed because the memleak is gone. Or isn't it?
Aha, I see that the change was made (again) as part of commit af4b26f5812b. This bug can be closed; I just tested Git master and the memory leak is gone. Thank you!