Calling modal oparators (e.g. bpy.ops.mesh.bevel via INVOKE_DEFAULT), then switching to object mode crashes #116422
Labels
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116422
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 531.41
Blender Version
Worked: version: 3.4.1, branch: blender-v3.4-release, commit date: 2022-12-19 17:00, hash:
rB55485cb379f7
Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash:
9be62e85b727
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2023-12-20 21:33, hash:
e470edf3e167
Short description of error
Simple script (provided below) that creates a plane, calls bpy.ops.mesh.bevel(...) and switches between Edit/Object mode crashes in current release of Blender 4.02 as well as current daily build.
PS: Thanks to all developers and testers of Blender for their hard work!
Exact steps for others to reproduce the error
QUICK-VERSION: Open attached crash.blend; Press: Alt+P -> CRASH
Step by Step (for End2End test creation):
This is the output when run in Power Shell when blender crashes:
Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF67C1158B6
Module : blender.exe
Thread : 000058f0
Writing: C:\Users\Stefan\AppData\Local\Temp\crash.crash.txt
Contents of crash.crash.txt written for current Blender 4.1.0 (current daily build, downloaded some minutes ago):
Note: Blender does not crash when running the script via
blender.exe -b -P crash.py
; However, it crashes when called viablender.exe -P crash.py
(without the "-b"). So it seems related to the UI being visible. I attached the script "crash.py" (same as in the initial bug report message) for convenience.Can confirm a crash.
Problem is that you are running the operator in
INVOKE_DEFAULT
which will enter the modal phase of the operator (so it waits for mouse input etc).Then switching to object mode from here crashes.
I do recall there was another report about a similar issue, will try to find it.
Same is true for any modal operator btw. it is not specific to bevel
Why do you want to switch to object mode when calling the operator with
INVOKE_DEFAULT
?If you know what values you want to bevel with, use
EXEC_DEFAULT
, if you want the modal operator, dont switch to object mode immediately.That being said, it might be reasonable to stop all running operators when switching modes
Hi @lichtwerk
Thanks for checking and confirming the crash and the additional info on why this happens.
I'm new to Blender scripting and used Chat GPT to generate me something; effectively, I'm still learning to wrap my head around how the API works and had no special intention apart from just rounding the corners of a plane. I then switched to the current version of Blender, just to make sure I don't have to later migrate my code or learn any new/changed API in addition, and the script crashed Blender. I just felt like this should not happen... especially, as it was quite some work to isolate the lines of code that effectively caused the crash.
I tried "EXEC_DEFAULT", which does not crash. So this is probably what I want.
HOWEVER: In my opinion, no script that calls should crash Blender, as this could lead to data loss and is a very bad user experience (doesn't make the application seam stable, causes frustration to repeatedly start, try something but save it somehow without destroying the last working version, ...). Exceptions are maybe out of memory conditions.
Well, if you try, there are many ways to make blender crash from python ;)
For some background, I would suggest looking at https://docs.blender.org/api/4.1/bpy.ops.html#execution-context and related pages, not sure if ChatGPT is the best source to dive into the PyAPI [but I am an old fart -- what do I know...]
While I would agree that preventing crashes is always good, but for this one I am pretty sure this will not be considered a bug, since it is just "wrong" usage really.
Crash after bpy.ops.mesh.bevel() calledto Calling modal oparators (e.g. bpy.ops.mesh.bevel via INVOKE_DEFAULT), then switching to object mode crashes