Page MenuHome

Blender crashes on mesh from pydata with empty polygon
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GT 630M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 382.05

Blender Version
Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: rB0f45cab862b8
Worked: ?

Short description of error
Blender crashes when creating a mesh from python data via script (when using no vertices, no edges and one face without vertices).

Exact steps for others to reproduce the error
default startup: run this:

import bpy
mesh = bpy.data.meshes.new("mesh")
mesh.from_pydata([], [], [[]])

Event Timeline

The warning for the method says Invalid mesh data (out of range indices, edges with matching indices, 2 sided faces… etc) are not prevented.
A polygon with less than three vertices is definitely invalid. Personally, I think that users of this api should make sure that their data is at least somewhat valid. If the function would have to verify everything, it would become slower for common use cases.

Robert Guetzkow (rjg) closed this task as Archived.EditedJan 29 2021, 1:55 PM

This falls into the category of quirks when using Blender's API as it is often just thin layer of abstraction on top of C or C++ code. Providing invalid data to a function like this can cause a crash and that is expected.

I'm closing this ticket as invalid as this is a known trade-off between performance and validation / reliability in the design of Blender's Python API. The Gotcha page documents more incorrect uses of the Python API that may lead to a crash.