godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.07k stars 21.18k forks source link

Godot crashes when using extended Translation class in script #44046

Open o01eg opened 3 years ago

o01eg commented 3 years ago

Godot version:

3.2.3

OS/device including version:

Gentoo AMD64 Linux

Issue description:

Godot crashes on finalization

[1] /lib64/libc.so.6(+0x38ac0) [0x7f42c9364ac0] (??:0)
[2] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x862a7b] (godot-3.2.3-stable/./core/string_name.h:100)
[3] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x2ce3697] (godot-3.2.3-stable/core/object.cpp:935)
[4] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x1491d99] (godot-3.2.3-stable/./core/os/memory.h:114)
[5] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x2d5000a] (godot-3.2.3-stable/./core/reference.h:279)
[6] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x2d50309] (godot-3.2.3-stable/./core/set.h:121)
[7] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x7e159a] (godot-3.2.3-stable/./core/os/memory.h:119)
[8] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x7d1a79] (godot-3.2.3-stable/main/main.cpp:2277)
[9] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x7a5323] (godot-3.2.3-stable/platform/x11/godot_x11.cpp:59)
[10] /lib64/libc.so.6(__libc_start_main+0xeb) [0x7f42c934fe8b] (??:0)
[11] godot-3.2.3-stable/bin/godot.x11.opt.tools.64() [0x7a7b7a] (??:?)

Steps to reproduce: Run example as script with -s script.gd

Minimal reproduction project:

godot-translation-extending.zip

Calinou commented 3 years ago

This is likely related to https://github.com/godotengine/godot/issues/38294 and https://github.com/godotengine/godot-docs/issues/3460. I'm not sure if the Translation class is meant to be extended from a script.

Edit: OP has opened a proposal for this: https://github.com/godotengine/godot-proposals/issues/1926

o01eg commented 3 years ago

Yes, it related to them but that issues about memory management of such extended classes.

qarmin commented 3 years ago

Backtrace:

Translation [Translation:1165]
Translated String
ERROR: ~List: Condition "_first != __null" is true.
   At: ./core/self_list.h:112.
ERROR: ~List: Condition "_first != __null" is true.
   At: ./core/self_list.h:112.
modules/gdscript/gdscript.cpp:1288:124: runtime error: member access within null pointer of type 'struct GDScriptLanguage'
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] godots() [0x13a7c6a] (/mnt/Miecz/godot3.2/platform/x11/crash_handler_x11.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fd63dfd8210] (??:0)
[3] StringName::operator<(StringName const&) const (/mnt/Miecz/godot3.2/./core/string_name.h:100)
[4] Map<StringName, GDScriptFunction*, Comparator<StringName>, DefaultAllocator>::_find(StringName const&) const (/mnt/Miecz/godot3.2/./core/typedefs.h:292)
[5] Map<StringName, GDScriptFunction*, Comparator<StringName>, DefaultAllocator>::find(StringName const&) (/mnt/Miecz/godot3.2/./core/map.h:533)
[6] GDScriptInstance::notification(int) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1288)
[7] Object::notification(int, bool) (/mnt/Miecz/godot3.2/core/object.cpp:934)
[8] Object::_predelete() (/mnt/Miecz/godot3.2/core/object.cpp:388)
[9] predelete_handler(Object*) (/mnt/Miecz/godot3.2/core/object.cpp:2051)
[10] void memdelete<Translation>(Translation*) (/mnt/Miecz/godot3.2/./core/os/memory.h:114)
[11] Ref<Translation>::unref() (/mnt/Miecz/godot3.2/./core/reference.h:281)
[12] Ref<Translation>::~Ref() (/mnt/Miecz/godot3.2/./core/reference.h:296)
[13] Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::Element::~Element() (/mnt/Miecz/godot3.2/./core/set.h:50)
[14] void memdelete_allocator<Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::Element, DefaultAllocator>(Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::Element*) (/mnt/Miecz/godot3.2/./core/os/memory.h:130)
[15] Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::_cleanup_tree(Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::Element*) (/mnt/Miecz/godot3.2/./core/set.h:490)
[16] Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::clear() (/mnt/Miecz/godot3.2/./core/set.h:613)
[17] Set<Ref<Translation>, Comparator<Ref<Translation> >, DefaultAllocator>::~Set() (/mnt/Miecz/godot3.2/./core/set.h:634)
[18] TranslationServer::~TranslationServer() (/mnt/Miecz/godot3.2/core/translation.h:67)
[19] void memdelete<TranslationServer>(TranslationServer*) (/mnt/Miecz/godot3.2/./core/os/memory.h:119)
[20] Main::cleanup() (/mnt/Miecz/godot3.2/main/main.cpp:2273)
[21] godots(main+0x336) [0x139eb5c] (/mnt/Miecz/godot3.2/platform/x11/godot_x11.cpp:59)
[22] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fd63dfb90b3] (??:0)
[23] godots(_start+0x2e) [0x139e76e] (??:?)
akien-mga commented 3 years ago

This seems to be fixed in the master branch, possibly by the GDScript refactor. It's still reproducible in 3.2.4 RC 2.

akien-mga commented 3 years ago

Still reproducible in 3.4 RC 1 / latest 3.x (a1b282cc16a6519d97798c81f55f6626ba9eedef).

tcoxon commented 1 year ago

This still seems to affect 4.1.1-stable--at least with the reproducer I've attached here: scripted-translation-crash.zip

Run the reproducer from a terminal. When the window appears, close it. On linux, a backtrace is logged as you close the window:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.1.1.stable.official (bd6af8e0ea69167dd0627f3bd54f9105bda0f8b5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x39ab0) [0x7ffb1678fab0] (??:0)
[2] /usr/lib/libc.so.6(pthread_mutex_lock+0x4) [0x7ffb167e07b4] (??:0)
[3] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0x116acbf] (??:0)
[4] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0x4851261] (??:0)
[5] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0xf061c0] (??:0)
[6] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0xf06323] (??:0)
[7] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0xf0112a] (??:0)
[8] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0xe46c1a] (??:0)
[9] /usr/lib/libc.so.6(+0x23850) [0x7ffb16779850] (??:0)
[10] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7ffb1677990a] (??:0)
[11] /home/tc/lib/godot/Godot_v4.1.1-stable_linux.x86_64() [0xe777ae] (??:0)
-- END OF BACKTRACE --