godot: "Condition 'p_elem->_root!=this' is true." errors when adding nodes from a thread
Hi everyone,
I seem to be randomly getting these "Condition 'p_elem->_root!=this' is true."
errors. When they happen, it causes my “Errors” tab to fill up with messages. I had a look in core/self_list.h:59
to see what is up, but I’m afraid it’s all too technical for me. (^_^);
Has anyone else experienced this before, and/or know why it would be generated? Or that matter, what the error actually means? What’s strange is that it happens randomly, so I have no real way of investigating further.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 31 (16 by maintainers)
I wanted to add that disabling physics multi-threading seems resolve this issue, OR making sure to connect a signal as “deferred” if you are using multi-threading and that signal around a physics process (i.e., _body_entered).
I’m seeing this in 3.2.2. I have a thread that creates/adds Nodes. I’ve been adding locks everywhere that my Thread executes. But the problem is still there. I’m using C#.
Me too. I am still investigating where the problem is coming from exactly. I am using threads. It’s hard to tell if the problem is fixed though, because it happens sometimes (our favorite kind of error, right?)
Anyway, I am unsafely assuming the nature of problems that happen sometimes is probably thread-related. Godot 4 doesn’t really give error messages for bad things that happen in threads, which makes things more difficult.
I tried changing some code to take the
add_child
calls out of the thread and move them to the function that gets called once the thread is finished. The errors seem to have went away for now.setting bidirectional to false fixed that error for me
the error is triggered whenever a new object has to calculate a path between two astar nodes that were connected to each other twice (easy to do if you run code on each node to connect it to every other adjacent node, bidirectional = true)
it’s probably triggered from other things too, but I think in this case it’s worth breaking out the error into a more descriptive “You’re connecting your astar points twice, try setting bidirectional to false”
Most recently I got this in the 2.1 branch when calling
astar.get_point_path
after mistakenly making duplicate connections with bidirectional=true. It still spit out the path just fine. That was weird to debug.Probably obscure issue with user code. I will pray for you.