bm.*.sort() leads to strange bytes object and crashes occasionally #45939

Closed
opened 2015-08-28 22:49:29 +02:00 by CodeManX · 9 comments
Member

System Information
Windows 8.1, 64bit

Blender Version
Broken: 2.75a official

Short description of error

Exact steps for others to reproduce the error
Add a Plane, go to edit mode and run below script several times. It should eventually produce an error that bytes object does not have property "index" or "co". Subsequent runs of the script or clicks in viewport may crash Blender.

import bpy
import bmesh
import random

ob = bpy.context.object
assert ob.type == "MESH"
me = ob.data

bm = bmesh.from_edit_mesh(me)
new_order = list(range(len(bm.verts)))
random.shuffle(new_order)

for i, v in zip(new_order, bm.verts):
    v.index = i

print("shuffled indices:")
for v in bm.verts:
    print(v.index)

print("update index()")    
bm.verts.index_update()

print("indices returned to original order:")
for v in bm.verts:
    print(v.index, v.co.xy)

print("shuffling again, followed by a sort:")
for i, v in zip(new_order, bm.verts):
    v.index = i
bm.verts.sort()

for v in bm.verts:
    print(v.index, v.co.xy)
    
bmesh.update_edit_mesh(me)
**System Information** Windows 8.1, 64bit **Blender Version** Broken: 2.75a official **Short description of error** **Exact steps for others to reproduce the error** Add a Plane, go to edit mode and run below script several times. It should eventually produce an error that bytes object does not have property "index" or "co". Subsequent runs of the script or clicks in viewport may crash Blender. ``` import bpy import bmesh import random ob = bpy.context.object assert ob.type == "MESH" me = ob.data bm = bmesh.from_edit_mesh(me) new_order = list(range(len(bm.verts))) random.shuffle(new_order) for i, v in zip(new_order, bm.verts): v.index = i print("shuffled indices:") for v in bm.verts: print(v.index) print("update index()") bm.verts.index_update() print("indices returned to original order:") for v in bm.verts: print(v.index, v.co.xy) print("shuffling again, followed by a sort:") for i, v in zip(new_order, bm.verts): v.index = i bm.verts.sort() for v in bm.verts: print(v.index, v.co.xy) bmesh.update_edit_mesh(me) ```
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @CodeManX

Added subscriber: @CodeManX

Added subscribers: @ideasman42, @Sergey

Added subscribers: @ideasman42, @Sergey
Campbell Barton was assigned by Sergey Sharybin 2015-08-29 11:26:22 +02:00

Can confirm the crash, it actually happens first time you run the script with asan enabled.

I'm not sure if there's some obvious mistake in the py code, will let @ideasman42 to decide :)

Can confirm the crash, it actually happens first time you run the script with asan enabled. I'm not sure if there's some obvious mistake in the py code, will let @ideasman42 to decide :)

I can't get this to crash.
Even playing back animation (in edit-mode), while holding Enter, over the run script button - is working fine.

Tested with valgrind and asan, - no errors in either.

@Sergey, whats the report you get?

I can't get this to crash. Even playing back animation (in edit-mode), while holding Enter, over the run script button - is working fine. Tested with valgrind and asan, - no errors in either. @Sergey, whats the report you get?
Author
Member

All it prints to console is "Error: EXCEPTION_ACCESS_VIOLATION".

@Sergey / @ideasman42: What OS did you try this on? And what exact Blender version?

All it prints to console is "Error: EXCEPTION_ACCESS_VIOLATION". @Sergey / @ideasman42: What OS did you try this on? And what exact Blender version?
Author
Member

Error occurs at least on Windows 8, 64bit in every version since the introduction of sort(), which was 2.64 (had to adapt the test script, because update_edit_mesh() didn't exist back then). I tried 32 and 64 bit releases.

In 2.64, the error is slightly different: 'PyCapsule' object has no attribute 'index' .

It's definitely the sort() call, if I comment it out, everything is fine.

Error occurs at least on Windows 8, 64bit in every version since the introduction of sort(), which was 2.64 (had to adapt the test script, because update_edit_mesh() didn't exist back then). I tried 32 and 64 bit releases. In 2.64, the error is slightly different: 'PyCapsule' object has no attribute 'index' . It's definitely the sort() call, if I comment it out, everything is fine.

This issue was referenced by blender/blender@9304df5182

This issue was referenced by blender/blender@9304df51827f9040789364d8374ce12ef5c43e41

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
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-addons#45939
No description provided.