Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node tree state is inconsistent during NOTIFICATION_CHILD_ORDER_CHANGED #77870

Closed
RedworkDE opened this issue Jun 5, 2023 · 5 comments · Fixed by #78019
Closed

Node tree state is inconsistent during NOTIFICATION_CHILD_ORDER_CHANGED #77870

RedworkDE opened this issue Jun 5, 2023 · 5 comments · Fixed by #78019
Milestone

Comments

@RedworkDE
Copy link
Member

RedworkDE commented Jun 5, 2023

Godot version

543750a

Issue description

Looking into the cause of the Children name does not match parent name in hashtable, this is a bug. from #77845 and making notes in this issue before I forget what I wanted to report (again).

godot/scene/main/node.cpp

Lines 1432 to 1440 in 543750a

data.children_cache_dirty = true;
bool success = data.children.erase(p_child->data.name);
ERR_FAIL_COND_MSG(!success, "Children name does not match parent name in hashtable, this is a bug.");
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
emit_signal(SNAME("child_order_changed"));
p_child->data.parent = nullptr;
p_child->data.index = -1;

During NOTIFICATION_CHILD_ORDER_CHANGED the child node had been removed from the parents list of children, the child still has the parent set, making it possible to attempt to remove it from its parent again triggering the error.

Steps to reproduce

Add this script to any node and run

extends Node

var node : Node

func _ready():
	var n = Node.new()
	add_child(n)
	node = n
	remove_child(n)

func _notification(what):
	if what == NOTIFICATION_CHILD_ORDER_CHANGED && node && node.get_parent() == self:
		remove_child(node)

Minimal reproduction project

Test_77870.zip

@Sauermann
Copy link
Contributor

It is likely, that merging #77867 will hide this issue, so that a more elaborate setup will be required to trigger it.

@RedworkDE
Copy link
Member Author

So while the current error was added in #75627 this issue is actually really old, and exists in some form since 2018 when NOTIFICATION_MOVED_IN_PARENT was first added in #23564.

@Omgesus
Copy link

Omgesus commented Jun 9, 2023

Just got the bug mentioned in the main post ("Children name does not match parent name in hashtable, this is a bug.") after updating from 4.0.3. Running through the terminal, it threw a ton of warnings (like the one at the beginning, but I only kept the one instead of the dozens for brevity's sake), gave the said error as well as "Condition "data.parent" is true" and a backtrace.

Edit: Forgot to mention, this happens whenever I try to change the active scene in the editor; I can open 4.1B1 to my previously open scene, but trying to swap scene tabs crashes, regardless of the view (Script, 2D or 3D).

Figure add this here in case it helps in some way.

WARNING: Parent path './MobileGates001/StaticBody3D' for node 'CollisionShape3D' has vanished when instantiating: 'res://Subscenes/Mansion/IndRooms/CentralRooms/mobile_elevator_gate.tscn'.
     at: instantiate (scene/resources/packed_scene.cpp:125)
ERROR: Children name does not match parent name in hashtable, this is a bug.
   at: remove_child (scene/main/node.cpp:1426)
ERROR: Condition "data.parent" is true.
   at: ~Node (scene/main/node.cpp:3519)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.beta1.official (828ec2c5d005b6499c7c4c88beaf81767d05614b)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x39ab0) [0x7f60c3bf0ab0] (??:0)
[2] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a1] (??:0)
[3] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[4] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[5] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[6] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[7] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[8] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[9] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[10] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[11] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[12] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[13] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[14] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[15] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[16] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[17] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[18] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[19] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2cbdd60] (??:0)
[20] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47776a4] (??:0)
[21] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x12d6c7a] (??:0)
[22] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x1dce661] (??:0)
[23] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x47e4051] (??:0)
[24] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2fbc1ab] (??:0)
[25] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2fbcda5] (??:0)
[26] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2d03d50] (??:0)
[27] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2d40d0e] (??:0)
[28] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2d42c7a] (??:0)
[29] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x2d69b05] (??:0)
[30] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0xea42b0] (??:0)
[31] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x4547e13] (??:0)
[32] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0x454905e] (??:0)
[33] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0xea495f] (??:0)
[34] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0xe34473] (??:0)
[35] /usr/lib/libc.so.6(+0x23850) [0x7f60c3bda850] (??:0)
[36] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7f60c3bda90a] (??:0)
[37] /home/drew/Documents/Godot_v4.1-beta1_linux.x86_64() [0xe6534e] (??:0)
-- END OF BACKTRACE --

@RedworkDE
Copy link
Member Author

@Omgesus Can you open a new issue for that and include a project, there seem to be bigger issues than just this (this issue shouldn't result in crashes)

@Omgesus
Copy link

Omgesus commented Jun 9, 2023

@RedworkDE I think I figured things out. I left the room while the project was reimporting (1100+ files takes a little bit, even on good hardware :p), and when I came back Godot had closed. My guess is that it crashed while importing and a few scenes were corrupted, and then it crashed trying to load some bad data. I did a git reset on my project and reimported everything, and it has been working so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants