Page MenuHome

Deadlock in BKE_libblock_remap_locked
Closed, ResolvedPublic

Description

Broken: latest master
working: 2.78a
Platform: Windows

I was looking into https://github.com/nortikin/sverchok/issues/1047#issuecomment-267672765 cause the sverchok people seemed to be at their wits end,
it's a deadlock due to recursive calls to pthread_spin_lock (pthread docs state : The results are undefined if the calling thread holds the lock at the time the call is made.)
which apparently means "meh fine! lets carry on!" on linux, but "let me wait for this lock to become available" on windows.

Initial lock :

>	blender.exe!BKE_main_lock(Main * bmain) Line 1262	C
 	blender.exe!BKE_libblock_unlink(Main * bmain, void * idv, const bool do_flag_never_null, const bool do_skip_indirect) Line 592	C
 	blender.exe!BKE_libblock_free_us(Main * bmain, void * idv) Line 895	C
 	blender.exe!ED_base_object_free_and_unlink(Main * bmain, Scene * scene, Base * base) Line 1126	C
 	blender.exe!object_delete_exec(bContext * C, wmOperator * op) Line 1174	C
 	blender.exe!wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only) Line 1109	C
 	blender.exe!wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const bool poll_only) Line 1297	C
 	blender.exe!WM_operator_name_call_ptr(bContext * C, wmOperatorType * ot, short context, PointerRNA * properties) Line 1343	C
 	blender.exe!ui_apply_but_funcs_after(bContext * C) Line 776	C
 	blender.exe!ui_popup_handler(bContext * C, const wmEvent * event, void * userdata) Line 10139	C
 	blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler * handler, const wmEvent * event, int always_pass) Line 451	C
 	blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2058	C
 	blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2145	C
 	blender.exe!wm_event_do_handlers(bContext * C) Line 2418	C
 	blender.exe!WM_main(bContext * C) Line 492	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 529	C
 	[External Code]

Later on

>	blender.exe!BKE_main_lock(Main * bmain) Line 1262	C
 	blender.exe!BKE_libblock_alloc(Main * bmain, short type, const unsigned char * name) Line 977	C
 	blender.exe!BKE_libblock_copy(Main * bmain, ID * id) Line 1138	C
 	blender.exe!BKE_mesh_copy(Main * bmain, Mesh * me) Line 505	C
 	blender.exe!BKE_mesh_new_from_object(Main * bmain, Scene * sce, Object * ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) Line 2325	C
 	blender.exe!rna_Main_meshes_new_from_object(Main * bmain, ReportList * reports, Scene * sce, Object * ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) Line 311	C
 	blender.exe!rna_Object_to_mesh(Object * ob, ReportList * reports, Scene * sce, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) Line 147	C
 	blender.exe!Object_to_mesh_call(bContext * C, ReportList * reports, PointerRNA * _ptr, ParameterList * _parms) Line 3988	C
 	blender.exe!RNA_function_call(bContext * C, ReportList * reports, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Line 6232	C
 	blender.exe!pyrna_func_call(BPy_FunctionRNA * self, _object * args, _object * kw) Line 5553	C
 	python35.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2167	C
 	python35.dll!do_call(_object * func, _object * * * pp_stack, int na, int nk) Line 4936	C
 	python35.dll!call_function(_object * * * pp_stack, int oparg) Line 4734	C
 	python35.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3239	C
 	python35.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4804	C
 	python35.dll!call_function(_object * * * pp_stack, int oparg) Line 4730	C
 	python35.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3239	C
 	python35.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4018	C
 	python35.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4818	C
 	python35.dll!call_function(_object * * * pp_stack, int oparg) Line 4730	C
 	python35.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3239	C
 	python35.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4804	C
 	python35.dll!call_function(_object * * * pp_stack, int oparg) Line 4730	C
 	python35.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3239	C
 	python35.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4018	C
 	python35.dll!fast_function(_object * func, _object * * * pp_stack, int n, int na, int nk) Line 4818	C
 	python35.dll!call_function(_object * * * pp_stack, int oparg) Line 4730	C
 	python35.dll!PyEval_EvalFrameEx(_frame * f, int throwflag) Line 3239	C
 	python35.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * * args, int argcount, _object * * kws, int kwcount, _object * * defs, int defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4018	C
 	python35.dll!function_call(_object * func, _object * arg, _object * kw) Line 627	C
 	python35.dll!PyObject_Call(_object * func, _object * arg, _object * kw) Line 2167	C
 	blender.exe!bpy_class_call(bContext * C, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Line 7611	C
 	blender.exe!rna_NodeTree_update_reg(bNodeTree * ntree) Line 541	C
 	blender.exe!ntreeUpdateTree(Main * bmain, bNodeTree * ntree) Line 3013	C
 	blender.exe!libblock_remap_data_postprocess_nodetree_update(Main * bmain, ID * new_id) Line 387	C
 	blender.exe!BKE_libblock_remap_locked(Main * bmain, void * old_idv, void * new_idv, const short remap_flags) Line 569	C
 	blender.exe!BKE_libblock_unlink(Main * bmain, void * idv, const bool do_flag_never_null, const bool do_skip_indirect) Line 596	C
 	blender.exe!BKE_libblock_free_us(Main * bmain, void * idv) Line 895	C
 	blender.exe!ED_base_object_free_and_unlink(Main * bmain, Scene * scene, Base * base) Line 1126	C
 	blender.exe!object_delete_exec(bContext * C, wmOperator * op) Line 1174	C
 	blender.exe!wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only) Line 1109	C
 	blender.exe!wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const bool poll_only) Line 1297	C
 	blender.exe!WM_operator_name_call_ptr(bContext * C, wmOperatorType * ot, short context, PointerRNA * properties) Line 1343	C
 	blender.exe!ui_apply_but_funcs_after(bContext * C) Line 776	C
 	blender.exe!ui_popup_handler(bContext * C, const wmEvent * event, void * userdata) Line 10139	C
 	blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler * handler, const wmEvent * event, int always_pass) Line 451	C
 	blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2058	C
 	blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2145	C
 	blender.exe!wm_event_do_handlers(bContext * C) Line 2418	C
 	blender.exe!WM_main(bContext * C) Line 492	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 529	C
 	[External Code]

Event Timeline

Ray Molenkamp (LazyDodo) created this task.EditedJan 7 2017, 4:08 AM

mont29 you know the relink code better than anyone else, mind taking a peek here?

Bastien Montagne (mont29) lowered the priority of this task from 90 to 50.

Nice catch… Though am totally unsure whether nodes should create new data-blocks in update function, this sounds pretty suspicious to me. But then, Sverchok is a giant hack around Blender anyway.

I suppose it won’t be an issue to unlock around the post update call for nodetrees, though I would definitively prefer not to have to. :|