Page MenuHome

Crash when creating Geometry Nodes through python
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: AMD FirePro W2100 ATI Technologies Inc. 4.5.13493 Core Profile Context FireGL 22.19.693.256

Blender Version
Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-03-18 02:55, hash: rBdecfd5c1699a
Worked: n/a

Short description of error
It looks like there's some form of memory corruption in the node tree validation code as it doesn't happen entirely 100% of the time.

Basically it happens when trying to setup a very simple node tree as follows (it does succeed sometimes):

Exact steps for others to reproduce the error

  • Load the attached file
  • Run the python script that's included in the script editor
  • Execute the test.add_geonode operator through the F3 menu
  • Observe a crash most of the time (there's a comment in the script if you can't get it to crash reliably)
Exception thrown: read access violation.
**from** was 0xFFFFFFFFFFFFFF57.

blender.exe!ntree_check_nodes_connected_dfs(bNodeTree * ntree, bNode * from, bNode * to) Line 71	C
blender.exe!ntree_check_nodes_connected(bNodeTree * ntree, bNode * from, bNode * to) Line 96	C
blender.exe!node_connected_to_output(Main * bmain, bNodeTree * ntree, bNode * node) Line 157	C
blender.exe!ED_node_tag_update_nodetree(Main * bmain, bNodeTree * ntree, bNode * node) Line 171	C++
blender.exe!rna_NodeTree_link_new(bNodeTree * ntree, Main * bmain, ReportList * reports, bNodeSocket * fromsock, bNodeSocket * tosock, bool verify_limits) Line 1222	C
blender.exe!NodeLinks_new_call(bContext * C, ReportList * reports, PointerRNA * _ptr, ParameterList * _parms) Line 44207	C
blender.exe!RNA_function_call(bContext * C, ReportList * reports, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Line 7552	C
blender.exe!pyrna_func_call(BPy_FunctionRNA * self, _object * args, _object * kw) Line 6362	C
[External Code]	
blender.exe!bpy_class_call(bContext * C, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Line 8567	C
blender.exe!rna_operator_execute_cb(bContext * C, wmOperator * op) Line 1313	C

Event Timeline

Not getting a crash (also uncommenting), but apparently the Property does not match the socket type [which to me is unexpected]

ERROR (bke.modifier): source/blender/blenkernel/intern/modifier.c:457 BKE_modifier_set_error: Object: "empty", Modifier: "node_cylinder", Property type does not match input socket "(Depth)"
ERROR (bke.modifier): source/blender/blenkernel/intern/modifier.c:457 BKE_modifier_set_error: Object: "empty", Modifier: "node_cylinder", Property type does not match input socket "(Radius)"

Did a bit more debugging:

  • The problem starts in rna_NodeTree_link_new with the call to nodeAddLink returning a valid pointer and storing to ret
  • Unfortunately a few lines later, ntreeUpdateTree ends up freeing the memory that ret was pointing to
  • ntreeUpdateTree does this when it attempts to "update individual nodes" per the comment in that function
  • The updatefunc leads to node_group_input_update where the memory is realloc'd elsewhere

And yeah, the property type not matching I will file separately once this bug clears just in case it's related.

You cannot create group inputs and outputs by linking to the "empty" socket from Python. Instead you have to explicitly add them on the node tree before linking to them. You do that by calling node_group.inputs.new(...) (see https://docs.blender.org/api/current/bpy.types.NodeTreeInputs.html)
I recommend you to create the inputs and outputs on the node group before creating the Group Input/Output nodes. Not sure if it is necessary, but it might work better in some cases.

You can reopen this report if that does not fix your problem. In that case, please also update the script in the initial post.