Dragging a sub-collection out of a scene-linked collection into the "Scene Collection" crashes reliably #83050

Closed
opened 2020-11-26 13:19:31 +01:00 by Dirk Wallenstein · 17 comments

System Information
Operating system: Kubuntu 20.04
Graphics card: nvidia TU106 GeForce RTX 2060 SUPER

Blender Version
Broken: 2.91 flatpak on Kubuntu
Worked: 2.82 (I guess 2.90 too)

Short description of error

Dragging a sub-collection out of a scene-linked collection into the "Scene Collection" crashes reliably.

This happens only in the original scene, not in the new scene.

Exact steps for others to reproduce the error

  • Factory startup
  • create a sub-collection ("collection 1") in the default collection
  • create a linked copy of the scene
  • return to the first scene
  • drag and drop collection 1 into the scene collection

In the blend, only the last step.

minimal.blend

**System Information** Operating system: Kubuntu 20.04 Graphics card: nvidia TU106 GeForce RTX 2060 SUPER **Blender Version** Broken: 2.91 flatpak on Kubuntu Worked: 2.82 (I guess 2.90 too) **Short description of error** Dragging a sub-collection out of a scene-linked collection into the "Scene Collection" crashes reliably. This happens only in the original scene, not in the new scene. **Exact steps for others to reproduce the error** - Factory startup - create a sub-collection ("collection 1") in the default collection - create a linked copy of the scene - return to the first scene - drag and drop collection 1 into the scene collection In the blend, only the last step. [minimal.blend](https://archive.blender.org/developer/F9380526/minimal.blend)

Added subscriber: @d-egg

Added subscriber: @d-egg

Added subscribers: @HooglyBoogly, @rjg

Added subscribers: @HooglyBoogly, @rjg

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

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

I can confirm this crash. @HooglyBoogly This seems very similar to #82439 that was supposed to be fixed by c645da98d8.

_BLI_assert_abort() Line 51	C
layer_collection_flags_restore(ListBase * flags, const Collection * collection) Line 1818	C
BKE_collection_move(Main * bmain, Collection * to_parent, Collection * from_parent, Collection * relative, bool relative_after, Collection * collection) Line 1886	C
collection_drop_invoke(bContext * C, wmOperator * UNUSED_op, const wmEvent * event) Line 1290	C
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1296	C
wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const bool poll_only, wmEvent * event) Line 1542	C
wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2789	C
wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2872	C
wm_event_do_handlers(bContext * C) Line 3368	C
WM_main(bContext * C) Line 638	C
main(int argc, const unsigned char * * UNUSED_argv_c) Line 526	C
I can confirm this crash. @HooglyBoogly This seems very similar to #82439 that was supposed to be fixed by c645da98d8. ``` _BLI_assert_abort() Line 51 C layer_collection_flags_restore(ListBase * flags, const Collection * collection) Line 1818 C BKE_collection_move(Main * bmain, Collection * to_parent, Collection * from_parent, Collection * relative, bool relative_after, Collection * collection) Line 1886 C collection_drop_invoke(bContext * C, wmOperator * UNUSED_op, const wmEvent * event) Line 1290 C wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1296 C wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const bool poll_only, wmEvent * event) Line 1542 C wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2789 C wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2872 C wm_event_do_handlers(bContext * C) Line 3368 C WM_main(bContext * C) Line 638 C main(int argc, const unsigned char * * UNUSED_argv_c) Line 526 C ```
Contributor

Added subscriber: @Raimund58

Added subscriber: @Raimund58
Hans Goudey self-assigned this 2020-11-26 14:59:50 +01:00
Member

Oh no.. I can reproduce this too. Should have released with a simple NULL check after that assert. Thanks for the report anyway.

Oh no.. I can reproduce this too. Should have released with a simple NULL check after that assert. Thanks for the report anyway.

Added subscriber: @Blender_Render

Added subscriber: @Blender_Render

Added subscriber: @mont29

Added subscriber: @mont29

@HooglyBoogly are you on this? that kind of issues should be fixed sooner than later...

@HooglyBoogly are you on this? that kind of issues should be fixed sooner than later...
Member

@mont29 Yes, sorry for the delay, I'll get to this today.

@mont29 Yes, sorry for the delay, I'll get to this today.
Member

So I've discovered why this happens, it's basically because moving collections that are also in linked scenes just doesn't work properly. Or at least that's how it seems, maybe that's expected.

Here's a short summary. The second scene, "Scene.001", was created with the "Linked Copy" option:

Before Move Move After Move
image.png Screenshot from 2020-12-06 18-49-49.png image.png
image.png image.png

The following patch just removes the assert and the NULL de-referencing in this situation. In the scope of this situation I think it's the right thing to do, the whole behavior of moving collections when there are linked scenes is far in "undefined behavior" territory for me.

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 5eec788255d..69fd682203f 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1773,6 +1773,15 @@ static void layer_collection_flags_store(Main *bmain,
   }
 }
 
+static void layer_collection_flags_free_recursive(LayerCollectionFlag *flag)
+{
+  LISTBASE_FOREACH (LayerCollectionFlag *, child, &flag->children) {
+    layer_collection_flags_free_recursive(child);
+  }
+
+  BLI_freelistN(&flag->children);
+}
+
 static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection,
                                                      LayerCollectionFlag *flag)
 {
@@ -1788,7 +1797,6 @@ static void layer_collection_flags_restore_recursive(LayerCollection *layer_coll
 
     child_flag = child_flag->next;
   }
-  BLI_freelistN(&flag->children);
 
   /* We treat exclude as a special case.
    *
@@ -1814,10 +1822,13 @@ static void layer_collection_flags_restore(ListBase *flags, const Collection *co
 
     LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
         view_layer, collection);
-    /* The flags should only be added if the collection is in the view layer. */
-    BLI_assert(layer_collection != NULL);
-
-    layer_collection_flags_restore_recursive(layer_collection, flag);
+    /* The flags should only be added if the collection is the scene in the first place, which
+     * means that it should also be in the view layer. However, in "Linked Copy" scenes where the
+     * moved collection is completely removed from the heirarchy. */
+    if (layer_collection != NULL) {
+      layer_collection_flags_restore_recursive(layer_collection, flag);
+    }
+    layer_collection_flags_free_recursive(flag);
   }
 
   BLI_freelistN(flags);
So I've discovered why this happens, it's basically because moving collections that are also in linked scenes just doesn't work properly. Or at least that's how it seems, maybe that's expected. Here's a short summary. The second scene, "Scene.001", was created with the "Linked Copy" option: | Before Move | Move | After Move | | -- | -- | -- | | ![image.png](https://archive.blender.org/developer/F9482804/image.png) | ![Screenshot from 2020-12-06 18-49-49.png](https://archive.blender.org/developer/F9482847/Screenshot_from_2020-12-06_18-49-49.png) | ![image.png](https://archive.blender.org/developer/F9482856/image.png) | | ![image.png](https://archive.blender.org/developer/F9482806/image.png) | | ![image.png](https://archive.blender.org/developer/F9482861/image.png) | The following patch just removes the assert and the NULL de-referencing in this situation. In the scope of this situation I think it's the right thing to do, the whole behavior of moving collections when there are linked scenes is far in "undefined behavior" territory for me. ```lines=10 diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 5eec788255d..69fd682203f 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1773,6 +1773,15 @@ static void layer_collection_flags_store(Main *bmain, } } +static void layer_collection_flags_free_recursive(LayerCollectionFlag *flag) +{ + LISTBASE_FOREACH (LayerCollectionFlag *, child, &flag->children) { + layer_collection_flags_free_recursive(child); + } + + BLI_freelistN(&flag->children); +} + static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection, LayerCollectionFlag *flag) { @@ -1788,7 +1797,6 @@ static void layer_collection_flags_restore_recursive(LayerCollection *layer_coll child_flag = child_flag->next; } - BLI_freelistN(&flag->children); /* We treat exclude as a special case. * @@ -1814,10 +1822,13 @@ static void layer_collection_flags_restore(ListBase *flags, const Collection *co LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); - /* The flags should only be added if the collection is in the view layer. */ - BLI_assert(layer_collection != NULL); - - layer_collection_flags_restore_recursive(layer_collection, flag); + /* The flags should only be added if the collection is the scene in the first place, which + * means that it should also be in the view layer. However, in "Linked Copy" scenes where the + * moved collection is completely removed from the heirarchy. */ + if (layer_collection != NULL) { + layer_collection_flags_restore_recursive(layer_collection, flag); + } + layer_collection_flags_free_recursive(flag); } BLI_freelistN(flags); ```
Member

Actually, when I wrote that last comment I forgot about they key information that this only happens when moving to the scene collection, moving the collection anywhere else works fine. In this case I think it actually makes sense to look into fixing that instead.

Maybe that patch makes sense for a possible 2.91 corrective release though, since it may be simpler.

Actually, when I wrote that last comment I forgot about they key information that this only happens when moving to the scene collection, moving the collection anywhere else works fine. In this case I think it actually makes sense to look into fixing that instead. Maybe that patch makes sense for a possible 2.91 corrective release though, since it may be simpler.

Please keep 'linked'/'link' terminology for actually linked data from libraries. 'Linked copy' is a bit unfortunate naming we inherit from history, but resulting data is not linked at all, it's just sharing some data-blocks between origin and copy items (scene or any other ID), that's all.

Behavior described in pictures looks correct and expected to me, since even when two scenes share their sub-collections, their main one (the master collection) is always local to each scene and never shared.

Can you submit your patch as a proper review, so that we can comment on it?

Please keep 'linked'/'link' terminology for actually linked data from libraries. 'Linked copy' is a bit unfortunate naming we inherit from history, but resulting data is not linked at all, it's just sharing some data-blocks between origin and copy items (scene or any other ID), that's all. Behavior described in pictures looks correct and expected to me, since even when two scenes share their sub-collections, their main one (the master collection) is always local to each scene and never shared. Can you submit your patch as a proper review, so that we can comment on it?
Member

Hmm, thanks for the explanation. I wonder what a better name for "Linked Copy" would be.

Hmm, thanks for the explanation. I wonder what a better name for "Linked Copy" would be.

This issue was referenced by 47159f1609

This issue was referenced by 47159f1609c2bd4c259dd7cfbe23655ddb55a271

This issue was referenced by 97651f428b

This issue was referenced by 97651f428b6ae6901cbacd9805616fe96052bc9b
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Thomas Dinges added this to the 2.91 milestone 2023-02-08 16:20:08 +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
7 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#83050
No description provided.