Crash when appending object using operator called from template icon view, followed by undo #80217

Closed
opened 2020-08-29 13:22:46 +02:00 by MACHIN3 · 20 comments

System Information
Operating system: Linux-4.15.0-112-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken: version: 2.83.5, branch: master, commit date: 2020-08-19 06:07, hash: c2b144df39, 2.90 is also affected

Short description of error
I have an operator that appends an object from another file. Calling it and undoing right after, works as expected unless that same operator is called from an update function of an enum, storing preview collection items, as is done for template icon views. Blender will crash on 2.83.5 and 2.90.

append_obj_undo_crash_from_template_icon_view.zip

video demo

Exact steps for others to reproduce the error

  • Extract the above zip file and open append_obj_undo_crash_from_template_icon_view.blend
  • Run the script
  • In the 3d view sidebar, a new panel 'Append Object' appears under the Tool tab
  • In the Append Object panel, click on the thumbnail, and again on the blender icon inside
  • the append object op was called and a cube was appended to the scene
  • Undo
    • Blender should crash!!!
  • Start Blender again and run the script again
  • This time, run the append op using the button below the thumbnail, then undo again
    • Blender should not crash this time
**System Information** Operating system: Linux-4.15.0-112-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21 **Blender Version** Broken: version: 2.83.5, branch: master, commit date: 2020-08-19 06:07, hash: `c2b144df39`, 2.90 is also affected **Short description of error** I have an operator that appends an object from another file. Calling it and undoing right after, works as expected unless that same operator is called from an update function of an enum, storing preview collection items, as is done for template icon views. Blender will crash on 2.83.5 and 2.90. [append_obj_undo_crash_from_template_icon_view.zip](https://archive.blender.org/developer/F8818731/append_obj_undo_crash_from_template_icon_view.zip) [video demo ](https://www.youtube.com/watch?v=NUhugExZu1g) **Exact steps for others to reproduce the error** * Extract the above zip file and open append_obj_undo_crash_from_template_icon_view.blend * Run the script * In the 3d view sidebar, a new panel 'Append Object' appears under the Tool tab * In the Append Object panel, click on the thumbnail, and again on the blender icon inside - the append object op was called and a cube was appended to the scene * Undo - Blender should crash!!! * Start Blender again and run the script again * This time, run the append op using the button below the thumbnail, then undo again - Blender should not crash this time
Author

Added subscriber: @MACHIN3

Added subscriber: @MACHIN3

Added subscriber: @Pinnhead

Added subscriber: @Pinnhead

Exactly the same behaviour in

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 452.06

Blender Version
Broken: version: 2.90.0 Beta, branch: master, commit date: 2020-08-25 16:00, hash: 21cb6f09ff

Exactly the same behaviour in **System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 452.06 **Blender Version** Broken: version: 2.90.0 Beta, branch: master, commit date: 2020-08-25 16:00, hash: `21cb6f09ff`

Added subscriber: @gendosplace

Added subscriber: @gendosplace

Confirm crash.

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2070 Super / NVIDIA Corporation 4.5.0 NVIDIA 452.06

Blender Version
2.83.5, branch: master, commit date: 2020-08-19 06:07, hash: c2b144df39

Confirm crash. **System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce RTX 2070 Super / NVIDIA Corporation 4.5.0 NVIDIA 452.06 **Blender Version** 2.83.5, branch: master, commit date: 2020-08-19 06:07, hash: c2b144df39
Author

Added subscriber: @rjg

Added subscriber: @rjg
Author

@rjg Shouldn't this be BF Blender (2.90) too? It's confirmed two times to crash 2.90.

@rjg Shouldn't this be BF Blender (2.90) too? It's confirmed two times to crash 2.90.

@MACHIN3 Phabricator doesn't let me tag more than one version. I can add both tags in the UI but one is discarded when I save the edit. Therefore, I tagged to lowest version since any fix for 2.83 will always have to be checked for inclusion into the current release as well.

@MACHIN3 Phabricator doesn't let me tag more than one version. I can add both tags in the UI but one is discarded when I save the edit. Therefore, I tagged to lowest version since any fix for 2.83 will always have to be checked for inclusion into the current release as well.
Author

Understood, thanks!

Understood, thanks!

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

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

This can be easily reproduced with the provided instructions. base->object in BKE_scene_object_base_flag_sync_from_base was NULL.

BKE_scene_object_base_flag_sync_from_base(Base * base) Line 1779	C
BKE_scene_set_background(Main * bmain, Scene * scene) Line 990	C
setup_app_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 384	C
setup_app_blend_file_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 414	C
BKE_blendfile_read_from_memfile(bContext * C, MemFile * memfile, const BlendFileReadParams * params, ReportList * reports) Line 511	C
BKE_memfile_undo_decode(MemFileUndoData * mfu, const int undo_direction, const bool use_old_bmain_data, bContext * C) Line 87	C
memfile_undosys_step_decode(bContext * C, Main * bmain, UndoStep * us_p, int undo_direction, bool UNUSED_is_final) Line 192	C
undosys_step_decode(bContext * C, Main * bmain, UndoStack * ustack, UndoStep * us, int dir, bool is_final) Line 211	C
BKE_undosys_step_undo_with_data_ex(UndoStack * ustack, bContext * C, UndoStep * us, bool use_skip) Line 695	C
BKE_undosys_step_undo_with_data(UndoStack * ustack, bContext * C, UndoStep * us) Line 723	C
BKE_undosys_step_undo(UndoStack * ustack, bContext * C) Line 728	C
ed_undo_step_impl(bContext * C, int step, const unsigned char * undoname, int undo_index, ReportList * reports) Line 208	C
ed_undo_step_direction(bContext * C, int step, ReportList * reports) Line 272	C
ed_undo_exec(bContext * C, wmOperator * op) Line 407	C
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1312	C
wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Line 2131	C
wm_handlers_do_keymap_with_keymap_handler(bContext * C, wmEvent * event, ListBase * handlers, wmEventHandler_Keymap * handler, wmKeyMap * keymap, const bool do_debug_handler) Line 2441	C
wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2738	C
wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2865	C
wm_event_do_handlers(bContext * C) Line 3398	C
WM_main(bContext * C) Line 485	C
main(int argc, const unsigned char * * UNUSED_argv_c) Line 548	C
This can be easily reproduced with the provided instructions. `base->object` in `BKE_scene_object_base_flag_sync_from_base` was `NULL`. ``` BKE_scene_object_base_flag_sync_from_base(Base * base) Line 1779 C BKE_scene_set_background(Main * bmain, Scene * scene) Line 990 C setup_app_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 384 C setup_app_blend_file_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 414 C BKE_blendfile_read_from_memfile(bContext * C, MemFile * memfile, const BlendFileReadParams * params, ReportList * reports) Line 511 C BKE_memfile_undo_decode(MemFileUndoData * mfu, const int undo_direction, const bool use_old_bmain_data, bContext * C) Line 87 C memfile_undosys_step_decode(bContext * C, Main * bmain, UndoStep * us_p, int undo_direction, bool UNUSED_is_final) Line 192 C undosys_step_decode(bContext * C, Main * bmain, UndoStack * ustack, UndoStep * us, int dir, bool is_final) Line 211 C BKE_undosys_step_undo_with_data_ex(UndoStack * ustack, bContext * C, UndoStep * us, bool use_skip) Line 695 C BKE_undosys_step_undo_with_data(UndoStack * ustack, bContext * C, UndoStep * us) Line 723 C BKE_undosys_step_undo(UndoStack * ustack, bContext * C) Line 728 C ed_undo_step_impl(bContext * C, int step, const unsigned char * undoname, int undo_index, ReportList * reports) Line 208 C ed_undo_step_direction(bContext * C, int step, ReportList * reports) Line 272 C ed_undo_exec(bContext * C, wmOperator * op) Line 407 C wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1312 C wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Line 2131 C wm_handlers_do_keymap_with_keymap_handler(bContext * C, wmEvent * event, ListBase * handlers, wmEventHandler_Keymap * handler, wmKeyMap * keymap, const bool do_debug_handler) Line 2441 C wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2738 C wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2865 C wm_event_do_handlers(bContext * C) Line 3398 C WM_main(bContext * C) Line 485 C main(int argc, const unsigned char * * UNUSED_argv_c) Line 548 C ```
Member

Added subscriber: @DanielGrauer

Added subscriber: @DanielGrauer

Added subscriber: @mont29

Added subscriber: @mont29

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Bastien Montagne self-assigned this 2020-09-14 10:10:16 +02:00

Answer is very simple: don't do this. Never ever call an operator from a property update function, this is begging for all kind of issues. Just don't.

Answer is very simple: don't do this. Never ever call an operator from a property update function, this is begging for all kind of issues. Just don't.

@mont29 Perhaps this should be added to the Gotchas page, if it's a known limitation?

@mont29 Perhaps this should be added to the [Gotchas](https://docs.blender.org/api/current/info_gotcha.html#help-my-script-crashes-blender) page, if it's a known limitation?

@rjg Good point, this page needs some updates for undo/redo section too actually.

@rjg Good point, this page needs some updates for undo/redo section too actually.
Author

Since this is crashing Blender, and since it never was was problem before 2.83, I feel like this warants more than "don't do this".

Since this is crashing Blender, and since it never was was problem before 2.83, I feel like this warants more than "don't do this".

New undo code comes with more complexity and responsibility (old one, by nuking and reloading the whole blend file, was safer, since it was not possible to get invalid pointers out of it, if stored undo step was OK). Calling an operator from an update callback has never been recommended though, those callbacks are supposed to remain very fast and efficient, and as localized as possible. Especially messing with the Main database has always been rather bad idea, fact that it has been working previously was mere luck, definitively not by design.

New undo code comes with more complexity and responsibility (old one, by nuking and reloading the whole blend file, was safer, since it was not possible to get invalid pointers out of it, if stored undo step was OK). Calling an operator from an update callback has never been recommended though, those callbacks are supposed to remain very fast and efficient, and as localized as possible. Especially messing with the Main database has always been rather bad idea, fact that it has been working previously was mere luck, definitively not by design.
Author

Understood, thanks for clarifying!

Understood, thanks for clarifying!
Thomas Dinges added this to the 2.83 LTS milestone 2023-02-08 16:35:26 +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
6 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#80217
No description provided.