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

[3.x] Using Dictionary as own key crashes Godot #44195

Closed
johnfn opened this issue Dec 8, 2020 · 2 comments · Fixed by #80888 · May be fixed by #44251
Closed

[3.x] Using Dictionary as own key crashes Godot #44195

johnfn opened this issue Dec 8, 2020 · 2 comments · Fixed by #80888 · May be fixed by #44251

Comments

@johnfn
Copy link

johnfn commented Dec 8, 2020

Godot version:
3.2.3

OS/device including version:
MacOS Catalina 10.15.5

Issue description:
Write this code:

func _ready():
  var test = {}
  test[test] = test

The game crashes immediately when it hits this code.

@Calinou
Copy link
Member

Calinou commented Dec 8, 2020

I can confirm this on 3.2 Git 185520c.

Minimal reproduction project: test_cyclic_reference_crash.zip

Backtrace:

[1] /lib64/libc.so.6(+0x3da60) [0x7f2aba7bfa60] (??:0)
[2] Variant::hash() const (/home/hugo/Documents/Git/godotengine/godot-3.2/core/variant.cpp:2747)
[3] Dictionary::hash() const (/home/hugo/Documents/Git/godotengine/godot-3.2/core/dictionary.cpp:196)
[4] Variant::hash() const (/home/hugo/Documents/Git/godotengine/godot-3.2/core/variant.cpp:2884)
[5] VariantHasher::hash(Variant const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/variant.h:460)
[6] HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::create_element(Variant const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/hash_map.h:208)
[7] HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::set(HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::Pair const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/hash_map.h:273)
[8] HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::set(Variant const&, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element* const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/hash_map.h:258)
[9] OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::insert(Variant const&, Variant const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/ordered_hash_map.h:217)
[10] OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::operator[](Variant const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/./core/ordered_hash_map.h:253)
[11] Dictionary::operator[](Variant const&) (/home/hugo/Documents/Git/godotengine/godot-3.2/core/dictionary.cpp:81)
[12] Variant::set(Variant const&, Variant const&, bool*) (/home/hugo/Documents/Git/godotengine/godot-3.2/core/variant_op.cpp:2190)
[13] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/home/hugo/Documents/Git/godotengine/godot-3.2/modules/gdscript/gdscript_function.cpp:579)
[14] GDScriptInstance::_ml_call_reversed(GDScript*, StringName const&, Variant const**, int) (/home/hugo/Documents/Git/godotengine/godot-3.2/modules/gdscript/gdscript.cpp:1269)
[15] GDScriptInstance::call_multilevel_reversed(StringName const&, Variant const**, int) (/home/hugo/Documents/Git/godotengine/godot-3.2/modules/gdscript/gdscript.cpp:1278)
[16] Node::_notification(int) (/home/hugo/Documents/Git/godotengine/godot-3.2/scene/main/node.cpp:152)
[17] Node::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot-3.2/./scene/main/node.h:46)
[18] CanvasItem::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot-3.2/./scene/2d/canvas_item.h:?)
[19] Node2D::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot-3.2/./scene/2d/node_2d.h:?)
[20] Object::notification(int, bool) (/home/hugo/Documents/Git/godotengine/godot-3.2/core/object.cpp:929)
[21] Node::_propagate_ready() (/home/hugo/Documents/Git/godotengine/godot-3.2/scene/main/node.cpp:196)
[22] Node::_propagate_ready() (/home/hugo/Documents/Git/godotengine/godot-3.2/scene/main/node.cpp:186)
[23] Node::_set_tree(SceneTree*) (/home/hugo/Documents/Git/godotengine/godot-3.2/scene/main/node.cpp:?)
[24] SceneTree::init() (/home/hugo/Documents/Git/godotengine/godot-3.2/scene/main/scene_tree.cpp:463)
[25] OS_X11::run() (/home/hugo/Documents/Git/godotengine/godot-3.2/platform/x11/os_x11.cpp:?)
[26] bin/godot.x11.tools.64.llvm(main+0x181) [0x261dc11] (/home/hugo/Documents/Git/godotengine/godot-3.2/platform/x11/godot_x11.cpp:56)
[27] /lib64/libc.so.6(__libc_start_main+0xf2) [0x7f2aba7aa1e2] (??:0)
[28] bin/godot.x11.tools.64.llvm(_start+0x2e) [0x261d9ce] (??:?)
-- END OF BACKTRACE --
[1]    69713 IOT instruction (core dumped)  bin/godot.x11.tools.64.llvm --path 

Demindiro added a commit to Demindiro/godot that referenced this issue Dec 10, 2020
@dalexeev dalexeev changed the title Cyclic object reference crashes Godot game [3.x] Using Dictionary as own key crashes Godot Aug 22, 2023
@akien-mga akien-mga added this to the 3.6 milestone Aug 28, 2023
@akien-mga
Copy link
Member

Fixed by #80888.

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