[Bf-blender-cvs] [5ae853d20a3] blender2.8: Fix (unreported) potential race condition in view_layer_bases_hash_create().
Bastien Montagne
noreply at git.blender.org
Mon Nov 5 20:29:49 CET 2018
Commit: 5ae853d20a3a5e41660220e684be1c7b785256d2
Author: Bastien Montagne
Date: Mon Nov 5 20:26:17 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB5ae853d20a3a5e41660220e684be1c7b785256d2
Fix (unreported) potential race condition in view_layer_bases_hash_create().
When you check for undone work before acquiring a lock that ensures you
are the only one actually doing the work, you have to redo the check
*after* acquiring said lock.
Otherwise, there is room for nasty random race condition issues...
===================================================================
M source/blender/blenkernel/intern/layer.c
===================================================================
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 65851bb032d..c259ec0da9c 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -305,14 +305,16 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer)
{
static ThreadMutex hash_lock = BLI_MUTEX_INITIALIZER;
- if (!view_layer->object_bases_hash) {
+ if (view_layer->object_bases_hash == NULL) {
BLI_mutex_lock(&hash_lock);
- view_layer->object_bases_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ if (view_layer->object_bases_hash == NULL) {
+ view_layer->object_bases_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if (base->object) {
- BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+ for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if (base->object) {
+ BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+ }
}
}
More information about the Bf-blender-cvs
mailing list