Page MenuHome

bvhtree.fromObject - error ( returned NULL without setting an error) in blender 2.8
Open, ConfirmedPublic

Description

x = bvhtree.BVHTree.FromObject(C.active_object, C.scene)
Is broken in blender 2.8 builds for some time now. I also tested on latest build from 4 December.

Error message:
raceback (most recent call last):

File "<blender_console>", line 1, in <module>

SystemError: <built-in method FromObject of type object at 0x0444CA30> returned NULL without setting an error

Details

Type
Bug

Event Timeline

Bastien Montagne (mont29) closed this task as Resolved.
Bastien Montagne (mont29) triaged this task as Confirmed priority.

For the record, the API changed, see e7c3f7ba6f1385a2138862de8568e571fa97b5b4.

Thanks for the fix. The operation bvhtree .fromObject now works when executed once. But it crashes on second run of operation each time:
Steps to reproduce:
run in console:

from mathutils.bvhtree import BVHTree
BVHTree.FromObject(C.active_object, C.depsgraph) 
BVHTree.FromObject(C.active_object, C.depsgraph)  #it will crash here (no error)

In addon I developed I have operator with some F6 props, and if I edit any F6 operator props, BVHTree.FromObject will crash blender. Simple operator example (run it 2x to to crash blender):

import bpy
from mathutils.bvhtree import BVHTree

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    

    def execute(self, context):
        sourceSurface_BVHT = BVHTree.FromObject(context.active_object, context.depsgraph) #crash on second run from F6 props
        print('Crash on second run')
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()

It actually crashes immediatelly with:
BLI_assert failed: //source/blender/blenkernel/intern/DerivedMesh.c:2192, mesh_get_eval_final(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'

For the records, I can "fix" the initial crash with P872, however when I call it the second time I indeed get a crash:

SUMMARY: AddressSanitizer: heap-use-after-free //source/blender/blenkernel/intern/DerivedMesh.c:2208 in mesh_get_eval_final
Full backtrace: P871

@Sergey Sharybin (sergey) suggestions?

Think your assert is a side effect. Surely, should be fixed, but don't think it will crash.

The P872 is wrong. Is ok to mock around with evaluated objects which you control and own (as in the baking), but you must not do such trickery for objects which are only "leased" to you ;) Doing such stuff will confuse regular evaluation routines.

The fact that crash is only happening on redo makes me believe that it's same type of errors where operator wants to know evaluated state of the scene an unless special flag is set for an operator, dependency graph is not guaranteed to be evaluated.