[Bf-blender-cvs] [a94d582a40f] blender2.8: Sculpt: Fix possible race condition with undo nodes

Sergey Sharybin noreply at git.blender.org
Tue Jul 3 11:07:38 CEST 2018


Commit: a94d582a40ffc06b19f0e4af6ba107c1433fcb1e
Author: Sergey Sharybin
Date:   Tue Jul 3 11:04:12 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa94d582a40ffc06b19f0e4af6ba107c1433fcb1e

Sculpt: Fix possible race condition with undo nodes

it is possible that two threads will request same undo node, only one
of them will initialize the node. The issue is that initialization is
happening outside of a lock, which was making one thread to use non-
initialized node.

If this change is ever a bottleneck, make a lock inside of node.

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_undo.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index bc22147b15d..61f7c3bd0d9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -931,9 +931,10 @@ SculptUndoNode *sculpt_undo_push_node(
 
 	unode = sculpt_undo_alloc_node(ob, node, type);
 
-	BLI_thread_unlock(LOCK_CUSTOM1);
-
-	/* copy threaded, hopefully this is the performance critical part */
+	/* NOTE: If this ever becomes a bottleneck, make a lock inside of the node.
+	 * so we release global lock sooner, but keep data locked for until it is
+	 * fully initialized.
+	 */
 
 	if (unode->grids) {
 		int totgrid, *grids;
@@ -970,6 +971,8 @@ SculptUndoNode *sculpt_undo_push_node(
 	if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
 	else unode->shapeName[0] = '\0';
 
+	BLI_thread_unlock(LOCK_CUSTOM1);
+
 	return unode;
 }



More information about the Bf-blender-cvs mailing list