Segfault with bmesh API on a mesh with a shape key #77584

Closed
opened 2020-06-07 22:58:55 +02:00 by Eelco Dolstra · 8 comments

System Information
Operating system: Linux (NixOS 20.03)
Graphics card: NVIDIA GeForce RTX 2070

Blender Version
Broken: 2.83, 2.90.0 alpha (2e52b3206c)
Worked: 2.82a and older

Short description of error

The following script crashes in Blender 2.83, but worked in previous versions:

import bpy
import bmesh
mesh = bpy.data.meshes.new("Test")
obj = bpy.data.objects.new("Test", mesh)
obj.shape_key_add(name="Basis")
bpy.context.scene.collection.objects.link(obj)
bpy.context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode="EDIT")
bm = bmesh.from_edit_mesh(obj.data)
vertex = bm.verts.new((2.0, 2.0, 2.0))
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT') # <-- crashes here
bpy.ops.object.mode_set(mode='OBJECT')

Removing obj.shape_key_add(name="Basis") makes the segfault disappear.

Here is a stack trace from gdb (from running blender -P ./script.py):

- 0  0x0000000000fa8ed6 in BM_mesh_bm_from_me ()
- 1  0x0000000000c7966e in BKE_mesh_to_bmesh_ex ()
- 2  0x0000000000c796bb in BKE_mesh_to_bmesh ()
- 3  0x00000000013aa97c in EDBM_mesh_make ()
- 4  0x00000000013f25a9 in ED_object_editmode_enter_ex ()
- 5  0x00000000013f292a in ?? ()
- 6  0x0000000000ec6a93 in ?? ()
- 7  0x0000000000ec6d07 in ?? ()
- 8  0x0000000000ec720a in WM_operator_name_call_ptr ()
- 9  0x00000000013f12ef in ?? ()
- 10 0x0000000000ec6a93 in ?? ()
- 11 0x0000000000ec7370 in WM_operator_call_py ()
- 12 0x0000000001207303 in ?? ()
- 13 0x000000000570f339 in _PyMethodDef_RawFastCallKeywords ()
- 14 0x000000000570f3f5 in _PyCFunction_FastCallKeywords ()
- 15 0x0000000000c11b20 in _PyEval_EvalFrameDefault ()
- 16 0x00000000057c0d8c in _PyEval_EvalCodeWithName ()
- 17 0x000000000570ecc0 in _PyFunction_FastCallDict ()
- 18 0x000000000570ff0d in _PyObject_Call_Prepend ()
- 19 0x000000000576b801 in ?? ()
- 20 0x000000000570f514 in _PyObject_FastCallKeywords ()
- 21 0x0000000000c0b4c5 in _PyEval_EvalFrameDefault ()
- 22 0x00000000057c0d8c in _PyEval_EvalCodeWithName ()
- 23 0x00000000057c0ebe in PyEval_EvalCodeEx ()
- 24 0x00000000057c0eeb in PyEval_EvalCode ()
- 25 0x00000000057f40e2 in PyRun_FileExFlags ()
- 26 0x00000000011f3681 in ?? ()
- 27 0x0000000000c135b8 in _start ()

Maybe this has something to do with https://developer.blender.org/D7818?

Exact steps for others to reproduce the error

  • In default scene go to the Text Editor
  • Copy and paste script above
  • Run script
    Crash
    Removing obj.shape_key_add(name="Basis") makes the segfault disappear.
**System Information** Operating system: Linux (NixOS 20.03) Graphics card: NVIDIA GeForce RTX 2070 **Blender Version** Broken: 2.83, 2.90.0 alpha (2e52b3206cc6) Worked: 2.82a and older **Short description of error** The following script crashes in Blender 2.83, but worked in previous versions: ``` import bpy import bmesh mesh = bpy.data.meshes.new("Test") obj = bpy.data.objects.new("Test", mesh) obj.shape_key_add(name="Basis") bpy.context.scene.collection.objects.link(obj) bpy.context.view_layer.objects.active = obj bpy.ops.object.mode_set(mode="EDIT") bm = bmesh.from_edit_mesh(obj.data) vertex = bm.verts.new((2.0, 2.0, 2.0)) bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='EDIT') # <-- crashes here bpy.ops.object.mode_set(mode='OBJECT') ``` Removing `obj.shape_key_add(name="Basis")` makes the segfault disappear. Here is a stack trace from gdb (from running `blender -P ./script.py`): ``` - 0 0x0000000000fa8ed6 in BM_mesh_bm_from_me () - 1 0x0000000000c7966e in BKE_mesh_to_bmesh_ex () - 2 0x0000000000c796bb in BKE_mesh_to_bmesh () - 3 0x00000000013aa97c in EDBM_mesh_make () - 4 0x00000000013f25a9 in ED_object_editmode_enter_ex () - 5 0x00000000013f292a in ?? () - 6 0x0000000000ec6a93 in ?? () - 7 0x0000000000ec6d07 in ?? () - 8 0x0000000000ec720a in WM_operator_name_call_ptr () - 9 0x00000000013f12ef in ?? () - 10 0x0000000000ec6a93 in ?? () - 11 0x0000000000ec7370 in WM_operator_call_py () - 12 0x0000000001207303 in ?? () - 13 0x000000000570f339 in _PyMethodDef_RawFastCallKeywords () - 14 0x000000000570f3f5 in _PyCFunction_FastCallKeywords () - 15 0x0000000000c11b20 in _PyEval_EvalFrameDefault () - 16 0x00000000057c0d8c in _PyEval_EvalCodeWithName () - 17 0x000000000570ecc0 in _PyFunction_FastCallDict () - 18 0x000000000570ff0d in _PyObject_Call_Prepend () - 19 0x000000000576b801 in ?? () - 20 0x000000000570f514 in _PyObject_FastCallKeywords () - 21 0x0000000000c0b4c5 in _PyEval_EvalFrameDefault () - 22 0x00000000057c0d8c in _PyEval_EvalCodeWithName () - 23 0x00000000057c0ebe in PyEval_EvalCodeEx () - 24 0x00000000057c0eeb in PyEval_EvalCode () - 25 0x00000000057f40e2 in PyRun_FileExFlags () - 26 0x00000000011f3681 in ?? () - 27 0x0000000000c135b8 in _start () ``` Maybe this has something to do with https://developer.blender.org/D7818? **Exact steps for others to reproduce the error** - In default scene go to the Text Editor - Copy and paste script above - Run script Crash Removing `obj.shape_key_add(name="Basis")` makes the segfault disappear.
Author

Added subscriber: @edolstra

Added subscriber: @edolstra

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

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

This issue was referenced by 39af4d8bfe

This issue was referenced by 39af4d8bfe389a3392d2f5e0af22fccafa1064c6

This issue was referenced by 46bdfcab10

This issue was referenced by 46bdfcab10fad857baffdbcfc1179838aed5660d

This issue was referenced by 1e186cea7c

This issue was referenced by 1e186cea7c2b1409d50070f040a571ac17290bbf

Added subscriber: @ideasman42

Added subscriber: @ideasman42

This crashes with the following steps too (not Python).

  • Enter edit-mode on the default cube.
  • Select all vertices and delete them.
  • Exit edit-mode.
  • Add a shape-key.
  • Exit edit mode.
  • Enter edit mode (crash).
This crashes with the following steps too (not Python). - Enter edit-mode on the default cube. - Select all vertices and delete them. - Exit edit-mode. - Add a shape-key. - Exit edit mode. - Enter edit mode (crash).

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Campbell Barton self-assigned this 2020-09-13 10:22:11 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 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#77584
No description provided.