bmesh.ops.bevel crash (Segfault) #57868

Closed
opened 2018-11-16 12:53:00 +01:00 by stephen leger · 7 comments
Member

System Information
Linux mint 18 / Nvidia 1070

Blender Version
Broken: 2.8 10bab568d3 (2018-11-14)
Worked:
2.79x

Short description of error
bmesh.ops.bevel crash Segfault

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps

Load factory, then run from py console


import bmesh
bpy.ops.object.mode_set(mode="EDIT")
bm = bmesh.from_edit_mesh(C.object.data)
geom = bm.edges[:]
bmesh.ops.bevel(bm,
                    geom=geom,
                    offset=0.1,
                    offset_type='OFFSET',
                    segments=1, 
                    profile=0.5,
                    vertex_only=False,
                    clamp_overlap=False,
                    material=-1)

Debug report:
BLI_assert failed: /home/stephen/blender-28-git/blender/source/blender/python/bmesh/bmesh_py_types.c:3798, BPy_BMElem_CreatePyObject(), at '0'

Blender 2.80 (sub 30), Commit date: 2018-11-14 16:15, Hash 10bab568d3

bpy.ops.object.editmode_toggle() # Operator

backtrace

/home/stephen/blender-28-git/build_linux_full/bin/blender(BLI_system_backtrace+0x33) [0x555a751abc93]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc1d4d0) [0x555a7471a4d0]
/lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7ff4f3c30f20]
/home/stephen/blender-28-git/build_linux_full/bin/blender(BM_mesh_bevel+0x1ee7) [0x555a74ce2fd7]
/home/stephen/blender-28-git/build_linux_full/bin/blender(bmo_bevel_exec+0x1ee) [0x555a74cf28de]
/home/stephen/blender-28-git/build_linux_full/bin/blender(BMO_op_exec+0x31) [0x555a74cc0c41]
/home/stephen/blender-28-git/build_linux_full/bin/blender(BPy_BMO_call+0x1c3) [0x555a74b1d0f3]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyObject_FastCallKeywords+0x11f) [0x555a7638d18f]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x3fc4) [0x555a74711b54]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalCodeWithName+0xa5a) [0x555a7644f14a]
/home/stephen/blender-28-git/build_linux_full/bin/blender(PyEval_EvalCode+0x23) [0x555a7644f223]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0x294f4c9) [0x555a7644c4c9]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyCFunction_FastCallKeywords+0x28a) [0x555a7638d5ca]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x8d1e) [0x555a747168ae]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalCodeWithName+0xa5a) [0x555a7644f14a]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyFunction_FastCallKeywords+0x8f) [0x555a7638cbff]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x72b5) [0x555a74714e45]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_PyFunction_FastCallDict+0x2b7) [0x555a7638cb57]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xfde724) [0x555a74adb724]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0x1627956) [0x555a75124956]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc226a6) [0x555a7471f6a6]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc25755) [0x555a74722755]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc25cf5) [0x555a74722cf5]
/home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc265ac) [0x555a747235ac]
/home/stephen/blender-28-git/build_linux_full/bin/blender(wm_event_do_handlers+0x5fa) [0x555a74723f2a]
/home/stephen/blender-28-git/build_linux_full/bin/blender(WM_main+0x20) [0x555a7471afa0]
/home/stephen/blender-28-git/build_linux_full/bin/blender(main+0x35a) [0x555a746f372a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ff4f3c13b97]
/home/stephen/blender-28-git/build_linux_full/bin/blender(_start+0x2a) [0x555a74716bfa]

**System Information** Linux mint 18 / Nvidia 1070 **Blender Version** Broken: 2.8 10bab568d33 (2018-11-14) Worked: 2.79x **Short description of error** bmesh.ops.bevel crash Segfault **Exact steps for others to reproduce the error** Based on a (as simple as possible) attached .blend file with minimum amount of steps Load factory, then run from py console ``` import bmesh bpy.ops.object.mode_set(mode="EDIT") bm = bmesh.from_edit_mesh(C.object.data) geom = bm.edges[:] bmesh.ops.bevel(bm, geom=geom, offset=0.1, offset_type='OFFSET', segments=1, profile=0.5, vertex_only=False, clamp_overlap=False, material=-1) ``` Debug report: BLI_assert failed: /home/stephen/blender-28-git/blender/source/blender/python/bmesh/bmesh_py_types.c:3798, BPy_BMElem_CreatePyObject(), at '0' # Blender 2.80 (sub 30), Commit date: 2018-11-14 16:15, Hash 10bab568d33 bpy.ops.object.editmode_toggle() # Operator # backtrace /home/stephen/blender-28-git/build_linux_full/bin/blender(BLI_system_backtrace+0x33) [0x555a751abc93] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc1d4d0) [0x555a7471a4d0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7ff4f3c30f20] /home/stephen/blender-28-git/build_linux_full/bin/blender(BM_mesh_bevel+0x1ee7) [0x555a74ce2fd7] /home/stephen/blender-28-git/build_linux_full/bin/blender(bmo_bevel_exec+0x1ee) [0x555a74cf28de] /home/stephen/blender-28-git/build_linux_full/bin/blender(BMO_op_exec+0x31) [0x555a74cc0c41] /home/stephen/blender-28-git/build_linux_full/bin/blender(BPy_BMO_call+0x1c3) [0x555a74b1d0f3] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyObject_FastCallKeywords+0x11f) [0x555a7638d18f] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x3fc4) [0x555a74711b54] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalCodeWithName+0xa5a) [0x555a7644f14a] /home/stephen/blender-28-git/build_linux_full/bin/blender(PyEval_EvalCode+0x23) [0x555a7644f223] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0x294f4c9) [0x555a7644c4c9] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyCFunction_FastCallKeywords+0x28a) [0x555a7638d5ca] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x8d1e) [0x555a747168ae] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalCodeWithName+0xa5a) [0x555a7644f14a] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyFunction_FastCallKeywords+0x8f) [0x555a7638cbff] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x628e) [0x555a74713e1e] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyEval_EvalFrameDefault+0x72b5) [0x555a74714e45] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc0faa7) [0x555a7470caa7] /home/stephen/blender-28-git/build_linux_full/bin/blender(_PyFunction_FastCallDict+0x2b7) [0x555a7638cb57] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xfde724) [0x555a74adb724] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0x1627956) [0x555a75124956] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc226a6) [0x555a7471f6a6] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc25755) [0x555a74722755] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc25cf5) [0x555a74722cf5] /home/stephen/blender-28-git/build_linux_full/bin/blender(+0xc265ac) [0x555a747235ac] /home/stephen/blender-28-git/build_linux_full/bin/blender(wm_event_do_handlers+0x5fa) [0x555a74723f2a] /home/stephen/blender-28-git/build_linux_full/bin/blender(WM_main+0x20) [0x555a7471afa0] /home/stephen/blender-28-git/build_linux_full/bin/blender(main+0x35a) [0x555a746f372a] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ff4f3c13b97] /home/stephen/blender-28-git/build_linux_full/bin/blender(_start+0x2a) [0x555a74716bfa]
Author
Member

Added subscriber: @StephenLeger

Added subscriber: @StephenLeger

Added subscribers: @howardt, @mont29

Added subscribers: @howardt, @mont29
Howard Trickey was assigned by Bastien Montagne 2018-11-26 21:39:26 +01:00

@howardt issue is that no vert is tagged, so bevel_vert_construct() is never called on any vert, and vert hash is empty… Will let you decide how to fix that. ;)

@howardt issue is that no vert is tagged, so bevel_vert_construct() is never called on any vert, and vert hash is empty… Will let you decide how to fix that. ;)
Author
Member

Might be lack of vertex/edges/faces select state of solidify output ?
Following code was working under 2.79:
(input geometry is a plane in edit mode)

import bmesh

bm = bmesh.from_edit_mesh(C.object.data)

geom = bm.faces[:]
verts = bm.verts[:]
edges = bm.edges[:]
bmesh.ops.solidify(bm, geom=geom, thickness=0.1)
for v in verts:
    v.co.z = 0.0

# bevel
for v in bm.verts:
    v.select = True

for v in verts:
    v.select = False

for v in bm.edges:
    v.select = True

for v in edges:
    v.select = False

geom = [v for v in bm.verts if v.select]
geom.extend([v for v in bm.edges if v.select])
bmesh.ops.bevel(bm,
    geom=geom,
    offset=0.05,
    offset_type='OFFSET',
    segments=1, 
    profile=0.5,
    vertex_only=False,
    clamp_overlap=False,
    material=-1,
    loop_slide=True,
    mark_seam=False,
    mark_sharp=False,
    strength=0.5,
    hnmode='FACE')

Might be lack of vertex/edges/faces select state of solidify output ? Following code was working under 2.79: (input geometry is a plane in edit mode) ``` import bmesh bm = bmesh.from_edit_mesh(C.object.data) geom = bm.faces[:] verts = bm.verts[:] edges = bm.edges[:] bmesh.ops.solidify(bm, geom=geom, thickness=0.1) for v in verts: v.co.z = 0.0 # bevel for v in bm.verts: v.select = True for v in verts: v.select = False for v in bm.edges: v.select = True for v in edges: v.select = False geom = [v for v in bm.verts if v.select] geom.extend([v for v in bm.edges if v.select]) bmesh.ops.bevel(bm, geom=geom, offset=0.05, offset_type='OFFSET', segments=1, profile=0.5, vertex_only=False, clamp_overlap=False, material=-1, loop_slide=True, mark_seam=False, mark_sharp=False, strength=0.5, hnmode='FACE') ```
Member

The immediate problem was that no verts were in the input geometry, and code assumed that if edges were there then verts were there. The code in the second update added the verts. But I fixed the code to add the verts from all edges explicitly so that this would no longer be necessary.

But then it crashed again because the update to do normals hardening had added an internal 'slot' containing some output normals in order to do hardening after the op ran. And then Python crashed trying to convert them into elements because the normals were not elements. I fixed that (though leaving a memory leak) and ran into yet another problem when switching back into 3d view mode - it crashes because of some inconsistency in the data the GPU uses to draw. The currently submitted code is in that state, so still not usable. i will try to figure out how to fix that.

Fixing the memory leak I think is best done in another way. Really, the normal hardening should happen inside the bmesh_bevel routine itself (otherwise the Op cannot do hardening!) and the whole idea of passing back normals through a slot can go away. But that is not a quick fix. But I hope to fix it soon.

The immediate problem was that no verts were in the input geometry, and code assumed that if edges were there then verts were there. The code in the second update added the verts. But I fixed the code to add the verts from all edges explicitly so that this would no longer be necessary. But then it crashed again because the update to do normals hardening had added an internal 'slot' containing some output normals in order to do hardening after the op ran. And then Python crashed trying to convert them into elements because the normals were not elements. I fixed that (though leaving a memory leak) and ran into yet another problem when switching back into 3d view mode - it crashes because of some inconsistency in the data the GPU uses to draw. The currently submitted code is in that state, so still not usable. i will try to figure out how to fix that. Fixing the memory leak I think is best done in another way. Really, the normal hardening should happen inside the bmesh_bevel routine itself (otherwise the Op cannot do hardening!) and the whole idea of passing back normals through a slot can go away. But that is not a quick fix. But I hope to fix it soon.
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

OK, so the crash was because one also needs to do a bmesh.update_edit_mesh(C.object.data) after running the above commands, and it is documented that one needs to do so. It all seems to work fine (though without hardening normals, if that is specified in the arguments) now.

So this bug is fixed, modulo the memory leak due to the code's weird use of a normals.out slot. I could add a flag to the BMSlot stuff to optionally have the free of a GHash also free the contents. But would rather not as I believe the correct thing to do is to refactor the code to remove the use of that slot altogether and use common code for hardening normals in both the modifier and the edit tool (right now they are separately implemented, and each has separate bugs). That will also fix the problem that runnning the op by itself will not actually hardent normals, if that is specified in the arguments.
I'll file another bug and assign it to me for that task.

OK, so the crash was because one also needs to do a bmesh.update_edit_mesh(C.object.data) after running the above commands, and it is documented that one needs to do so. It all seems to work fine (though without hardening normals, if that is specified in the arguments) now. So this bug is fixed, modulo the memory leak due to the code's weird use of a normals.out slot. I could add a flag to the BMSlot stuff to optionally have the free of a GHash also free the contents. But would rather not as I believe the correct thing to do is to refactor the code to remove the use of that slot altogether and use common code for hardening normals in both the modifier and the edit tool (right now they are separately implemented, and each has separate bugs). That will also fix the problem that runnning the op by itself will not actually hardent normals, if that is specified in the arguments. I'll file another bug and assign it to me for that task.
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
3 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#57868
No description provided.