Modal operator causes a crash when using the REDO operation #61738

Open
opened 2019-02-20 08:38:30 +01:00 by Jesse Yurkovich · 9 comments

System Information
Operating system: Win10
Graphics card: nVidia 1070

Blender Version
Broken: 2.80 (sub 45), branch: master, commit date: 2019-02-19 23:18, hash: 855b3e68ef, type: Release
Worked: n/a

Short description of error
A custom modal operator seems to cause an AccessViolation when you shift+r (REDO) the operator

Exact steps for others to reproduce the error
modal_redo_bug.blend

  • Open the provided blend and execute the script that is sitting in the script editor
  • Select the "Cube" object
  • Invoke the custom "DC Modal Redo Bug" operator from the Space/F3 search menu
    • Left click to confirm. Things are fine
  • Select "Cube" again
  • Shift-R to REDO
  • Left click to confirm
  • Crash
Exception thrown: read access violation.
op->type was 0xFFFFFFFFFFFFFF3F.


blender.exe!wm_operator_register(bContext * C, wmOperator * op) Line 164	C
blender.exe!wm_operator_finished(bContext * C, wmOperator * op, const bool repeat, const bool store) Line 923	C
blender.exe!wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties) Line 2028	C
blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2616	C
blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2660	C
blender.exe!wm_event_do_handlers(bContext * C) Line 3011	C
blender.exe!WM_main(bContext * C) Line 421	C
blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 507	C
**System Information** Operating system: Win10 Graphics card: nVidia 1070 **Blender Version** Broken: 2.80 (sub 45), branch: master, commit date: 2019-02-19 23:18, hash: 855b3e68ef27, type: Release Worked: n/a **Short description of error** A custom modal operator seems to cause an AccessViolation when you shift+r (REDO) the operator **Exact steps for others to reproduce the error** [modal_redo_bug.blend](https://archive.blender.org/developer/F6667717/modal_redo_bug.blend) - Open the provided blend and execute the script that is sitting in the script editor - Select the "Cube" object - Invoke the custom "DC Modal Redo Bug" operator from the Space/F3 search menu - Left click to confirm. Things are fine - Select "Cube" again - Shift-R to REDO - Left click to confirm - Crash ``` Exception thrown: read access violation. op->type was 0xFFFFFFFFFFFFFF3F. blender.exe!wm_operator_register(bContext * C, wmOperator * op) Line 164 C blender.exe!wm_operator_finished(bContext * C, wmOperator * op, const bool repeat, const bool store) Line 923 C blender.exe!wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties) Line 2028 C blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2616 C blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2660 C blender.exe!wm_event_do_handlers(bContext * C) Line 3011 C blender.exe!WM_main(bContext * C) Line 421 C blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 507 C ```
Author
Member

Added subscriber: @deadpin

Added subscriber: @deadpin
Campbell Barton was assigned by Jacques Lucke 2019-02-20 11:03:59 +01:00
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

@ideasman42, seems to be related to your refactoring of the wmEventHandler struct (thanks for that btw!).

@ideasman42, seems to be related to your refactoring of the `wmEventHandler` struct (thanks for that btw!).

This isn't a new issue it happens in 2.79b and isn't related to recent changes in 2.8.

While this is a bug in Blender, this code is working in a way that isn't supported.

The redo causes many instances of this operator to be called, reaches the maximum limit, then frees the first.

Our convention is to only register a modal operator on invoke, and perform an action on execute, if this is followed the error wont occur.

Looking over Blender's code, we never call WM_event_add_modal_handler from an execution callback, so it might be best to disable this altogether so modal operators can only be started by invoke.

This isn't a new issue it happens in 2.79b and isn't related to recent changes in 2.8. While this is a bug in Blender, this code is working in a way that isn't supported. The redo causes many instances of this operator to be called, reaches the maximum limit, then frees the first. Our convention is to only register a modal operator on `invoke`, and perform an action on `execute`, if this is followed the error wont occur. Looking over Blender's code, we never call `WM_event_add_modal_handler` from an execution callback, so it might be best to disable this altogether so modal operators can only be started by `invoke`.

Added subscriber: @brecht

Added subscriber: @brecht

Agree, modal handlers were never meant to be used from execute, it's for use together with invoke.

Agree, modal handlers were never meant to be used from execute, it's for use together with invoke.
Author
Member

Understood, this is unsupported here. +1 to disable this ability, somehow, if it doesn't add much code burden.

I can restructure my operator to handle the invoke vs. execute differences I think in the meantime.

Understood, this is unsupported here. +1 to disable this ability, somehow, if it doesn't add much code burden. I can restructure my operator to handle the invoke vs. execute differences I think in the meantime.
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:35:08 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @ckohl_art

Added subscriber: @ckohl_art
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:46 +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#61738
No description provided.