Overrides: Crash when removing unexisting library (heist scene) #101903

Closed
opened 2022-10-18 15:50:13 +02:00 by Jeroen Bakker · 4 comments
Member

Heist file location: storage/heist/pro/lib/sets/factory_floor/factory_floor.blend (e.g. r2780) contains reference to two animation files. When removing them blender crashes inside collection_object_cache_free where it contains a parent collection that contains a null reference.
At this moment of the process this is not allowed.

Current patch I used to investigate the issue.

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 751b5185e39..dc0a54865e8 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -841,8 +841,10 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection)
   return collection->object_cache_instanced;
 }
 
-static void collection_object_cache_free(Collection *collection)
+static void collection_object_cache_free(Collection *collection, int level)
 {
+  printf(
+      "%s %d: %p '%s' %p\n", __func__, level, collection, collection->id.name, collection->id.lib);
   /* Clear own cache an for all parents, since those are affected by changes as well. */
   collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
   collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
@@ -850,13 +852,17 @@ static void collection_object_cache_free(Collection *collection)
   BLI_freelistN(&collection->object_cache_instanced);
 
   LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
-    collection_object_cache_free(parent->collection);
+    printf(" - %p\n", parent->collection);
+    if (parent->collection == NULL) {
+      continue;
:...skipping...
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 751b5185e39..dc0a54865e8 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -841,8 +841,10 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection)
   return collection->object_cache_instanced;
 }
 
-static void collection_object_cache_free(Collection *collection)
+static void collection_object_cache_free(Collection *collection, int level)
 {
+  printf(
+      "%s %d: %p '%s' %p\n", __func__, level, collection, collection->id.name, collection->id.lib);
   /* Clear own cache an for all parents, since those are affected by changes as well. */
   collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
   collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
@@ -850,13 +852,17 @@ static void collection_object_cache_free(Collection *collection)
   BLI_freelistN(&collection->object_cache_instanced);
 
   LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
-    collection_object_cache_free(parent->collection);
+    printf(" - %p\n", parent->collection);
+    if (parent->collection == NULL) {
+      continue;
+    }
+    collection_object_cache_free(parent->collection, level + 1);
   }
 }
 
 void BKE_collection_object_cache_free(Collection *collection)
 {
-  collection_object_cache_free(collection);
+  collection_object_cache_free(collection, 0);
 }
 
 Base *BKE_collection_or_layer_objects(const Scene *scene,
@@ -1344,7 +1350,9 @@ static void collection_null_children_remove(Collection *collection)
 static void collection_missing_parents_remove(Collection *collection)
 {
   LISTBASE_FOREACH_MUTABLE (CollectionParent *, parent, &collection->parents) {
+    printf("%s: %p %p\n", __func__, parent, parent->collection);
     if ((parent->collection == NULL) || !collection_find_child(parent->collection, collection)) {
+      printf("%s: free\n", __func__);
       BLI_freelinkN(&collection->parents, parent);
     }
   }
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c
index addb7b0988c..950ea794997 100644
--- a/source/blender/blenkernel/intern/lib_remap.c
+++ b/source/blender/blenkernel/intern/lib_remap.c
@@ -362,6 +362,11 @@ static void libblock_remap_data_postprocess_collection_update(Main *bmain,
                                                               Collection *UNUSED(old_collection),
                                                               Collection *new_collection)
 {
+  static int time = 0;
+  time++;
+  if (time > 856) {
+    printf("%s: %p %p %d\n", __func__, owner_collection, new_collection, time);
+  }
   if (new_collection == NULL) {
     /* XXX Complex cases can lead to NULL pointers in other collections than old_collection,
      * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index 3c353a1c8c8..ac6878321e3 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -158,7 +158,7 @@ void *BLI_memarena_calloc(MemArena *ma, size_t size)
   BLI_assert(ma->use_calloc == false);
 
   ptr = BLI_memarena_alloc(ma, size);
-  BLI_assert(ptr != NULL);
+  //BLI_assert(ptr != NULL);
   memset(ptr, 0, size);
 
   return ptr;
Heist file location: `storage/heist/pro/lib/sets/factory_floor/factory_floor.blend` (e.g. r2780) contains reference to two animation files. When removing them blender crashes inside `collection_object_cache_free` where it contains a parent collection that contains a null reference. At this moment of the process this is not allowed. Current patch I used to investigate the issue. ``` diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 751b5185e39..dc0a54865e8 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -841,8 +841,10 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection) return collection->object_cache_instanced; } -static void collection_object_cache_free(Collection *collection) +static void collection_object_cache_free(Collection *collection, int level) { + printf( + "%s %d: %p '%s' %p\n", __func__, level, collection, collection->id.name, collection->id.lib); /* Clear own cache an for all parents, since those are affected by changes as well. */ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; @@ -850,13 +852,17 @@ static void collection_object_cache_free(Collection *collection) BLI_freelistN(&collection->object_cache_instanced); LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { - collection_object_cache_free(parent->collection); + printf(" - %p\n", parent->collection); + if (parent->collection == NULL) { + continue; :...skipping... diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 751b5185e39..dc0a54865e8 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -841,8 +841,10 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection) return collection->object_cache_instanced; } -static void collection_object_cache_free(Collection *collection) +static void collection_object_cache_free(Collection *collection, int level) { + printf( + "%s %d: %p '%s' %p\n", __func__, level, collection, collection->id.name, collection->id.lib); /* Clear own cache an for all parents, since those are affected by changes as well. */ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; @@ -850,13 +852,17 @@ static void collection_object_cache_free(Collection *collection) BLI_freelistN(&collection->object_cache_instanced); LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { - collection_object_cache_free(parent->collection); + printf(" - %p\n", parent->collection); + if (parent->collection == NULL) { + continue; + } + collection_object_cache_free(parent->collection, level + 1); } } void BKE_collection_object_cache_free(Collection *collection) { - collection_object_cache_free(collection); + collection_object_cache_free(collection, 0); } Base *BKE_collection_or_layer_objects(const Scene *scene, @@ -1344,7 +1350,9 @@ static void collection_null_children_remove(Collection *collection) static void collection_missing_parents_remove(Collection *collection) { LISTBASE_FOREACH_MUTABLE (CollectionParent *, parent, &collection->parents) { + printf("%s: %p %p\n", __func__, parent, parent->collection); if ((parent->collection == NULL) || !collection_find_child(parent->collection, collection)) { + printf("%s: free\n", __func__); BLI_freelinkN(&collection->parents, parent); } } diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index addb7b0988c..950ea794997 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -362,6 +362,11 @@ static void libblock_remap_data_postprocess_collection_update(Main *bmain, Collection *UNUSED(old_collection), Collection *new_collection) { + static int time = 0; + time++; + if (time > 856) { + printf("%s: %p %p %d\n", __func__, owner_collection, new_collection, time); + } if (new_collection == NULL) { /* XXX Complex cases can lead to NULL pointers in other collections than old_collection, * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c index 3c353a1c8c8..ac6878321e3 100644 --- a/source/blender/blenlib/intern/BLI_memarena.c +++ b/source/blender/blenlib/intern/BLI_memarena.c @@ -158,7 +158,7 @@ void *BLI_memarena_calloc(MemArena *ma, size_t size) BLI_assert(ma->use_calloc == false); ptr = BLI_memarena_alloc(ma, size); - BLI_assert(ptr != NULL); + //BLI_assert(ptr != NULL); memset(ptr, 0, size); return ptr; ```
Bastien Montagne was assigned by Jeroen Bakker 2022-10-18 15:50:13 +02:00
Author
Member

Added subscribers: @Jeroen-Bakker, @Beaug

Added subscribers: @Jeroen-Bakker, @Beaug

This issue was referenced by 514f4e8b47

This issue was referenced by 514f4e8b47bf4c3d57cf74780cb3b8178e8f1a19

This issue was referenced by a450a2f2b2

This issue was referenced by a450a2f2b288c5105f0d0522c440e82fb498e117

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Bastien Montagne added this to the Core project 2023-02-09 15:43:11 +01:00
Bastien Montagne removed this from the Core project 2023-02-09 18:19:07 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#101903
No description provided.