Page MenuHome

BVHTree Causes Crash When Calculated Twice on an Object
Closed, DuplicatePublic


System Information
Operating system: Win10
Graphics card: EVGA GTX970

Blender Version
Broken: BVHTree calculation
2.80, 9dde3e42a7c5, blender2.8, 2018-12-20

Short description of error
Scripting in Blender python, running a script that calculates BVHTree twice (for example, clicking RUN SCRIPT twice) on the same object causes crash.

Exact steps for others to reproduce the error
Put two cubes in a new file. Rename "s" and "t".
Open a new text editor and run the below code.
First time it runs fine. Run again and it will crash.
Reopen blender.
Run object "s". Runs OK.
Change code to run object "t". Runs OK.
Run either object again and it will crash.
I tried in 2.79 and it works ok (modifying for depsgraph of course).

import bpy
from mathutils.bvhtree import BVHTree

s = 's'
t = 't'

sc = bpy.context.depsgraph
bvhtree = BVHTree.FromObject([s], sc)



Event Timeline

Sebastian Parborg (zeddb) triaged this task as Confirmed priority.Fri, Dec 21, 7:10 PM

With a debug build I get this assert on first script run:
BLI_assert failed: /home/zed/programmering/blender_master/blender/source/blender/blenkernel/intern/DerivedMesh.c:2192, mesh_get_eval_final(), at 'ob->id.tag & LIB_TAG_COPIED_ON_WRITE'

release build backtrace:

Thread 1 "blender" received signal SIGSEGV, Segmentation fault.
0x0000555556752aae in CustomData_get_active_layer_index ()
(gdb) bt
#0  0x0000555556752aae in CustomData_get_active_layer_index ()
#1  0x0000555556753b09 in CustomData_get_layer ()
#2  0x0000555556472894 in C_BVHTree_FromObject ()
#3  0x00007ffff743a702 in _PyCFunction_FastCallDict () from /usr/lib64/
#4  0x00007ffff74a8e94 in call_function () from /usr/lib64/
#5  0x00007ffff74adbd6 in _PyEval_EvalFrameDefault () from /usr/lib64/
#6  0x00007ffff74a89c0 in _PyEval_EvalCodeWithName () from /usr/lib64/
#7  0x00007ffff74a8f22 in PyEval_EvalCodeEx () from /usr/lib64/
#8  0x00007ffff74a8f4b in PyEval_EvalCode () from /usr/lib64/
#9  0x0000555556431e0b in python_script_exec ()
#10 0x000055555615f1a6 in text_run_script ()
#11 0x000055555609263c in wm_operator_invoke ()
#12 0x0000555556092bc8 in wm_operator_call_internal ()
#13 0x0000555556092f8a in WM_operator_name_call_ptr ()
#14 0x000055555623eacf in ui_apply_but_funcs_after ()
#15 0x000055555624edbc in ui_handler_region_menu ()
#16 0x000055555609589a in wm_handlers_do_intern ()
#17 0x000055555609625c in wm_handlers_do ()
#18 0x0000555556096a54 in wm_event_do_handlers ()
#19 0x000055555608e300 in WM_main ()
#20 0x000055555607a44b in main ()

@Sergey Sharybin (sergey) COW related?