Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorlazydodo <github@lazydodo.com>2016-11-25 22:02:37 +0300
committerlazydodo <github@lazydodo.com>2016-11-25 22:03:04 +0300
commit265e5def76cc08f633e8851236af1ee903d87ff0 (patch)
tree62682ef2ac8ae8dcc4eb200c5dfc684d7b5a03be /intern
parentbcd0d8584fbd000a4b2b835f33b7c89fe15609fc (diff)
Fix T50104, Race condition in SVMShaderManager::device_update_shader
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/render/svm.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 9d3f49a3c84..955b892f4c3 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -71,14 +71,13 @@ void SVMShaderManager::device_update_shader(Scene *scene,
scene->light_manager->need_update = true;
}
- /* We only calculate offset and do re-allocation from the locked block,
- * actual copy we do after the lock is releases to hopefully gain some
- * percent of performance.
+ /* The copy needs to be done inside the lock, if another thread resizes the array
+ * while memcpy is running, it'll be copying into possibly invalid/freed ram.
*/
nodes_lock_.lock();
size_t global_nodes_size = global_svm_nodes->size();
global_svm_nodes->resize(global_nodes_size + svm_nodes.size());
- nodes_lock_.unlock();
+
/* Offset local SVM nodes to a global address space. */
int4& jump_node = global_svm_nodes->at(shader->id);
jump_node.y = svm_nodes[0].y + global_nodes_size - 1;
@@ -88,6 +87,7 @@ void SVMShaderManager::device_update_shader(Scene *scene,
memcpy(&global_svm_nodes->at(global_nodes_size),
&svm_nodes[1],
sizeof(int4) * (svm_nodes.size() - 1));
+ nodes_lock_.unlock();
}
void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)