diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-02 20:08:36 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-02 20:08:36 +0300 |
commit | 5a3b7c532952d29e1ee3b26aba10a91b5bc3af31 (patch) | |
tree | d08b090a30fbb2535636ec2303bd554f523a2d5b /source/blender/blenkernel/BKE_node_ui_storage.hh | |
parent | 3a29c19b2bffdd664981543c2f68151a6520b48b (diff) |
Fix Node UI Storage Threading Issues
Since the same node tree can be used in modifiers on different objects,
there can be multiple threads writing to the maps in the node tree UI
storage at the same time. The additions for attribute name hints and
error messages made it so this would often cause a crash or at least
an ASAN report. This patch adds locks to prevent multiple threads
from using the maps concurrently.
In a brief test I actually didn't observe a crash without the global
`bNodeTree` UI storage mutex, but I think it's necessary for the change
to be correct, and I did notice some unfreed memory without it anyway.
Ideally it would be in a node tree runtime struct though.
Differential Revision: https://developer.blender.org/D10577
Diffstat (limited to 'source/blender/blenkernel/BKE_node_ui_storage.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_node_ui_storage.hh | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh b/source/blender/blenkernel/BKE_node_ui_storage.hh index 231eb11d473..a49ff988272 100644 --- a/source/blender/blenkernel/BKE_node_ui_storage.hh +++ b/source/blender/blenkernel/BKE_node_ui_storage.hh @@ -16,6 +16,8 @@ #pragma once +#include <mutex> + #include "BLI_hash.hh" #include "BLI_map.hh" #include "BLI_session_uuid.h" @@ -82,6 +84,7 @@ struct NodeUIStorage { struct NodeTreeUIStorage { blender::Map<NodeTreeEvaluationContext, blender::Map<std::string, NodeUIStorage>> context_map; + std::mutex context_map_mutex; }; const NodeUIStorage *BKE_node_tree_ui_storage_get_from_context(const bContext *C, |