diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-06-18 14:52:09 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-06-18 14:57:46 +0300 |
commit | 847b66e81de83653cacd1eb1eb503245cd156e31 (patch) | |
tree | 545f73f27432356f394cca2193f4bb8f4574c497 /source/blender | |
parent | b8cf8e0bc2e15e4f67f98b85d45390e39a7ed4c8 (diff) |
Fix T88394: crash when editing animated Alembic properties
When an object, whose mesh gets loaded from Alembic, gets animated in
Blender and the Alembic CacheFile datablock also gets animated, editing
keyframes causes both datablock to be re-copied for evaluation. This
caused a threading issue and a double-free of some memory. This is fixed
by expanding the scope of the spin lock in
`BKE_cachefile_reader_free()`.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/cachefile.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index feae033337d..30e9ae39b67 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -198,6 +198,9 @@ void BKE_cachefile_reader_open(CacheFile *cache_file, void BKE_cachefile_reader_free(CacheFile *cache_file, struct CacheReader **reader) { #ifdef WITH_ALEMBIC + /* Multiple modifiers and constraints can call this function concurrently, and + * cachefile_handle_free() can also be called at the same time. */ + BLI_spin_lock(&spin); if (*reader != NULL) { if (cache_file) { BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE); @@ -206,13 +209,11 @@ void BKE_cachefile_reader_free(CacheFile *cache_file, struct CacheReader **reade CacheReader_free(*reader); *reader = NULL; - /* Multiple modifiers and constraints can call this function concurrently. */ - BLI_spin_lock(&spin); if (cache_file && cache_file->handle_readers) { BLI_gset_remove(cache_file->handle_readers, reader, NULL); } - BLI_spin_unlock(&spin); } + BLI_spin_unlock(&spin); #else UNUSED_VARS(cache_file, reader); #endif |