From abbc43e4e419c44e6d0134aec051d543a0944b3e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Jan 2021 17:12:27 +0100 Subject: Fix T84397: Creating and removing many objects very quickly causes a crash The root of the issue was caused by the dependency graph using ID pointer to map evaluated state from old depsgraph to new one upon relations update. This was failing when IDs were re-allocated rapidly: was possible that Object ID's evaluated state assigned to Mesh and vice versa. Now depsgraph uses Session UUID to identify which IDs to restore evaluated state to. The session UUID is stored in the IDNode, so that id_orig is not dereferenced on depsgraph update since the ID might be freed. The root of the issue is identified by Campbell, original patch was done by Bastien, thanks! Also thanks to Oliver and Ray and everyone else for testing! --- source/blender/depsgraph/intern/node/deg_node_id.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender/depsgraph/intern/node/deg_node_id.h') diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h index 04a9006ac10..c4d36685bb8 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.h +++ b/source/blender/depsgraph/intern/node/deg_node_id.h @@ -74,12 +74,22 @@ struct IDNode : public Node { IDComponentsMask get_visible_components_mask() const; - /* ID Block referenced. */ /* Type of the ID stored separately, so it's possible to perform check whether CoW is needed * without de-referencing the id_cow (which is not safe when ID is NOT covered by CoW and has * been deleted from the main database.) */ ID_Type id_type; + + /* ID Block referenced. */ ID *id_orig; + + /* Session-wide UUID of the id_orig. + * Is used on relations update to map evaluated state from old nodes to the new ones, without + * relying on pointers (which are not guaranteed to be unique) and without dereferencing id_orig + * which could be "stale" pointer. */ + uint id_orig_session_uuid; + + /* Evaluated datablock. + * Will be covered by the copy-on-write system if the ID Type needs it. */ ID *id_cow; /* Hash to make it faster to look up components. */ -- cgit v1.2.3