Linux, Debian
Broken: dc3f073d1c52 current master branch
I get non-deterministic/random segfaults on rendering (cycles). I would guess approximately on every 5th frame. Also sometimes. on the first rendering after launching blender. I am not able to fully render a single shot in my current project, so it's an absolute show-stopper for myself at least.
I can reproduce this in various form in a rather complex setup involving a 5k locs inhouse addon. Depending on the the scene update, I get rather different stacktraces, but I guess it's one and the same problem (related to depsgraph).
To reproduce:
- Run the included python addon
- With the default scene in 2.81a
- Render an animation. The segfault may only happen after quite some frames.
bl_info = {
"name": "Crash Min Ex",
"author": "Aurel Wildfellner",
"blender": (2, 81, 0),
"location": "3D View > Toolbox",
"description": "to reproduce a render crash",
"warning": "",
"wiki_url": "",
"support": 'TESTING',
"category": "Mesh"}
if "bpy" in locals():
import importlib
else:{F8323293}
import bpy
from bpy.app.handlers import persistent
def generateCubeMeshData():
tri_vertices = []
tri_indices = []
tri_vertices.append([1,1,1])
tri_vertices.append([-1,1,1])
tri_vertices.append([1,-1,1])
tri_vertices.append([-1,-1,1])
tri_vertices.append([1,1,-1])
tri_vertices.append([-1,1,-1])
tri_vertices.append([1,-1,-1])
tri_vertices.append([-1,-1,-1])
tri_indices.append([0, 1, 2])
tri_indices.append([1, 3, 2])
tri_indices.append([4, 5, 7])
tri_indices.append([5, 8, 6])
tri_indices.append([1, 0, 5])
tri_indices.append([5, 4, 0])
return (tri_vertices, tri_indices)
def removeSupportMeshes(context):
#FIXME this seems to be the correct way, but we still get
# constant growing of memory footprint.
scn = context.scene
objects_to_be_removed = []
for obj in scn.objects:
if "support_mesh_foo" in obj.name:
objects_to_be_removed.append(obj.name)
for objname in objects_to_be_removed:
bpy.data.meshes.remove(scn.objects[objname].data,
do_unlink=True)
#bpy.data.objects.remove(scn.objects[objname],
# do_unlink=True)
context.view_layer.update()
def buildGeometry(context):
print("Build Geometry")
scn = context.scene
# store active object's name, so we can reselect
old_active_obj_name = ""
if hasattr(bpy.context, "active_object"):
if bpy.context.active_object:
old_active_obj_name = bpy.context.active_object.name
removeSupportMeshes(context)
support_mesh_name = "support_mesh_foo"
smesh = bpy.data.meshes.new(support_mesh_name)
sobj = bpy.data.objects.new(support_mesh_name, smesh)
# add mesh data
tri_vertices, tri_indices = generateCubeMeshData()
smesh.from_pydata(tri_vertices, [], tri_indices)
## update scene
scn.collection.objects.link(sobj)
context.view_layer.update()
if old_active_obj_name in scn.objects:
print("setting active object....")
context.view_layer.objects.active = \
scn.objects[old_active_obj_name]
scn.objects[old_active_obj_name].select_set(True)
context.view_layer.update()
@persistent
def postFrameChangeHandler(scn):
print("FRAME CHANGE")
buildGeometry(bpy.context)
def register():
## register handler
bpy.app.handlers.frame_change_post.append(postFrameChangeHandler)
def unregister():
for op in operator_cls:
bpy.utils.unregister_class(op)I am rather confused about when I should and should not call view_layer.update() after adding/removing mesh objects in the scene. However I get crashes also without updating the view_layer.
I get the following stacktrace for the segfault:
# Blender 2.81 (sub 16), Commit date: 2019-12-04 11:32, Hash f1aa4d18d49d # backtrace ./blender(BLI_system_backtrace+0x1d) [0x14ee84d] ./blender() [0x12cbb79] /lib/x86_64-linux-gnu/libc.so.6(+0x37840) [0x7f244c79f840] ./blender(_ZN3DEG29deg_copy_on_write_is_expandedEPK2ID+0) [0x150dc10] ./blender(_ZN3DEG20DepsgraphNodeBuilder11begin_buildEv+0xd7) [0x14ffd37] ./blender(DEG_graph_build_from_view_layer+0x6d) [0x14f45dd] ./blender() [0x13f9043] ./blender(wm_event_do_depsgraph+0xc3) [0x16a1d63] ./blender(wm_event_do_refresh_wm_and_depsgraph+0x87) [0x16a1ec7] ./blender(wm_event_do_notifiers+0x472) [0x16a79f2] ./blender(WM_main+0x28) [0x169dcd8] ./blender(main+0x2fe) [0x1237f7e] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7f244c78c09b] ./blender() [0x12c849c]