Page MenuHome

Python API: segmentation fault on UNDO after duplicating objects from Application timer
Closed, DuplicatePublicBUG

Description

System Information
Operating system: Linux-5.4.0-47-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: Radeon RX 570 Series ATI Technologies Inc. 4.5.14752 Core Profile Context 20.30

Blender Version
Broken: version: 2.90.0, branch: master, commit date: 2020-08-31 11:26, hash: rB0330d1af29c0
Worked: (newest version of Blender that worked as expected)

Short description of error
segmentation fault when duplicating objects using modal operator.
It doesn't happen using the legacy undo option.

Exact steps for others to reproduce the error

  • open the default cube scene, split the viewport ans switch to the text editor.
  • load the "Operator modal timer " example template.
  • add the following line at the end of the modal function: bpy.ops.object.duplicate()
  • run the script for a very few seconds and press ESC to stop it.
  • press Ctrl + Z in the viewport.
  • segfault

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Mon, Sep 14, 12:26 PM
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Can confirm.

Base has a NULL object here.

1   BKE_scene_object_base_flag_sync_from_base scene.c           1780 0x33b6a96 
2   BKE_scene_set_background                  scene.c           991  0x33b5244 
3   setup_app_data                            blendfile.c       382  0x4536c36 
4   setup_app_blend_file_data                 blendfile.c       412  0x4536cca 
5   BKE_blendfile_read_from_memfile           blendfile.c       510  0x4537096 
6   BKE_memfile_undo_decode                   blender_undo.c    87   0x4535fb6 
7   memfile_undosys_step_decode               memfile_undo.c    190  0x426e3c7 
8   undosys_step_decode                       undo_system.c     210  0x456fd8f 
9   BKE_undosys_step_undo_with_data_ex        undo_system.c     693  0x457145b 
10  BKE_undosys_step_undo_with_data           undo_system.c     722  0x45715bb 
11  BKE_undosys_step_undo                     undo_system.c     727  0x45715e8 
12  ed_undo_step_impl                         ed_undo.c         207  0x426c319 
13  ed_undo_step_direction                    ed_undo.c         271  0x426c60a 
14  ed_undo_exec                              ed_undo.c         407  0x426cabe 
15  wm_operator_invoke                        wm_event_system.c 1313 0x36b3a92 
16  wm_handler_operator_call                  wm_event_system.c 2132 0x36b57f4 
17  wm_handlers_do_keymap_with_keymap_handler wm_event_system.c 2442 0x36b64c3 
18  wm_handlers_do_intern                     wm_event_system.c 2739 0x36b7413 
19  wm_handlers_do                            wm_event_system.c 2866 0x36b78d7 
20  wm_event_do_handlers                      wm_event_system.c 3399 0x36b903f

Think this is very much related to T62074: 2.8: Python API: crash due to missing window context in Application timer and T62051: 2.8: Python API: bpy.context.object not available in Application Timers though

Philipp Oeser (lichtwerk) renamed this task from segmentation fault when duplicating objects using modal operator. to Python API: segmentation fault on UNDO after duplicating objects from Application timer.Mon, Sep 14, 12:28 PM

Note that I think we could even consider disabling operator execution from timers, this seems to cause a lot of bugs since operators aren't written to run outside the main event loop where the context is setup and events are being properly handled.

Note that I think we could even consider disabling operator execution from timers, this seems to cause a lot of bugs since operators aren't written to run outside the main event loop where the context is setup and events are being properly handled.

I'm afraid this would break so many add-ons that rely on an event timer to implement interactivity and use operators to its functionality.

also, the same issue happens for modal operators that dont have a timer, and also happens if the user triggered the operator while another modal operator is running, regardless of if it has a timer.

Checking the test file, I was under the impression this was for bpy.app.timers, not modal operators.