Page MenuHome

Program hangs indefinitely when attempting to access any property of "link_loops" (BMElemSeq)
Closed, InvalidPublic

Description

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce RTX 2080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 432.00

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: rBf1aa4d18d49d
Worked: (optional)

Short description of error
Program hangs indefinitely when attempting to get length of, iterate, or access any element in "link_loops" property of BMElemSeq, of bmesh created from object in blend file:

Exact steps for others to reproduce the error

  1. load blend file
  1. Switch to Scripting View
  1. Run the following python script code:
import bmesh
obj = bpy.context.scene.objects[0]
bm = bmesh.new()
bm.from_mesh(obj.data)
bm.verts.ensure_lookup_table()
len(bm.verts[0].link_loops)

Event Timeline

Greg (pyro789x) updated the task description. (Show Details)
Greg (pyro789x) updated the task description. (Show Details)
Greg (pyro789x) renamed this task from Program hangs indefinitely when attempting to get list of, or iterate, "link_loops" property of BMElemSeq to Program hangs indefinitely when attempting to access any property of "link_loops" (BMElemSeq).Tue, Jan 7, 7:31 AM
Greg (pyro789x) updated the task description. (Show Details)

There's something very wrong with the geometry in that particular mesh. For example, there are edgeless faces (0 and 5). Attempting to cut an edge there manually (between verts 0 and 3) will also result in this freeze. Deleting both faces and trying to fill the hole with alt+f fills with "edgeless" faces again.

How was this mesh created? Is that an import? If this was created solely with Blender's tools, it'd be nice to find out how, exactly, such errors became even possible.

To "fix" the geometry you can run, in Python console, this (while being in object mode):

C.object.data.validate()

Greg (pyro789x) added a comment.EditedWed, Jan 8, 4:48 AM

Not sure if you consider it "with Blender's tools", but it was created with the "from_pydata()" function

Here's the raw input:

looks like throwing a blendMesh.validate() after blendMesh.from_pydata() does fix the issue. I wonder if from_pydata() should include an internal call to validate()?

Philipp Oeser (lichtwerk) claimed this task.

Thx for the report, but this does not look like a bug to me.
(I havent checked in detail -- debugging external scripts for the exact misusage is out of scope of the bugtracker in this case, sorry)

But there is already a fat warning in the docs regarding this:

Invalid mesh data (out of range indices, edges with matching indices, 2 sided faces… etc) are not prevented. If the data used for mesh creation isn’t known to be valid, run Mesh.validate after this function.

https://docs.blender.org/api/master/bpy.types.Mesh.html#bpy.types.Mesh.from_pydata

Closing as this is working as intended...

I wouldn't really classify it as a "script", the provided input is just providing a set of hardcoded vertices and faces. I'm also not seeing any of the issues you mention in the face list (out-of-range-indices, edges that contain the same index multiple times, or 2-sided faces, as each face is a simple triangle)