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 726838 - crash when unsetting GtkTreeView model
crash when unsetting GtkTreeView model
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Accessibility
3.11.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 726452 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-03-21 18:06 UTC by Oliver Gerlich
Modified: 2014-03-26 14:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Valgrind output for the Invalid read (6.01 KB, text/plain)
2014-03-21 18:06 UTC, Oliver Gerlich
Details
example app (1.03 KB, text/plain)
2014-03-21 18:29 UTC, Oliver Gerlich
Details
Valgrind output when calling gtk_tree_store_clear() instead (7.00 KB, text/plain)
2014-03-22 17:14 UTC, Oliver Gerlich
Details

Description Oliver Gerlich 2014-03-21 18:06:04 UTC
Created attachment 272587 [details]
Valgrind output for the Invalid read

When calling gtk_tree_view_set_model(NULL) (from Python), the application sometimes crashes. This was observed while chasing crashes in Gedit 3.12 in combination with gedit-file-search plugin.

I think I've narrowed it down to the following sequence of events:
- there's a GtkTreeview with a GtkTreestore, with two levels (some top-level nodes, most of them containing one or more children)
- the crash happens more likely if one of the child nodes has been selected with the mouse
- when the user clicks a button, treeview.set_model(None) is called
- this causes gtk_tree_view_accessible_notify_gtk() to be called, which clears its internal hash map containing cell infos (GtkTreeViewAccessibleCellInfo)
- this calls cell_info_free() for each cell info; not sure in which order the hash items are removed?
- cell_info_free() unrefs the corresponding GtkCellAccessible
- this might call gtk_cell_accessible_object_finalize(), which in turn checks for relations of type ATK_RELATION_NODE_CHILD_OF
- if such a relation exists, the GtkCellAccessible targets in this relation are unreffed as well
- so this apparently causes another cell info object to be finalized as wel (probably the parent line in the treeview?)
- however, this cell info still exists in the hash map; when it is later destroyed, cell_info_free() tries to access invalid memory and possibly crashes

A Valgrind log is attached (line numbers might be off a bit due to local debug prints).

This happens under Ubuntu 14.04 x86_64 in Virtualbox, with Gedit 3.12 and GTK 3.11, both from recent JHBuild.
Comment 1 Oliver Gerlich 2014-03-21 18:29:26 UTC
Created attachment 272588 [details]
example app

Here's a test case:
- run attached script
- in treeview, expand "bar" entry
- select "bar1" entry
- click on "Click here" button to call treeview.set_model(None)

Sometimes it crashes, sometimes it doesn't. Probably depends on the memory addresses of cell infos and how they are ordered in the hash map.
Comment 2 Oliver Gerlich 2014-03-22 17:14:24 UTC
Created attachment 272648 [details]
Valgrind output when calling gtk_tree_store_clear() instead

When calling gtk_tree_store_clear() instead of gtk_tree_view_set_model(), a similar crash can happen (again due to cell_info_free() freeing memory that is later freed again). Valgrind output is attached.
Comment 3 Benjamin Otte (Company) 2014-03-24 15:42:48 UTC
Should be fixed in git master. I expect there to be a bunch of duplicates in
bugzilla, so for every triager reading this: Whenever there's a crash with a
stack trace that ends up in a11y treeview code and it happened in March, it's
likely this one. Affected releases are 3.11.8 and 3.11.9, so no stable
releases should trigger it.
Another thing is that this crash only happens in trees, not in lists.
Comment 4 Benjamin Otte (Company) 2014-03-24 16:02:35 UTC
*** Bug 726452 has been marked as a duplicate of this bug. ***
Comment 5 John Lindgren 2014-03-26 14:53:27 UTC
I believe this properly fixes the crash that was first observed following the memory leak fix in commit 7a411eb6dd4d (which was later reverted in 4238cc4b7b96).  So 7a411eb6dd4d can be un-reverted now.

See also:
https://bugzilla.gnome.org/show_bug.cgi?id=695965
https://bugzilla.gnome.org/show_bug.cgi?id=722030