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

Crash when setting exported variable with setter with deferred call to a method with a script error #58468

Open
tliron opened this issue Feb 23, 2022 · 16 comments

Comments

@tliron
Copy link

tliron commented Feb 23, 2022

Godot version

4.0.alpha3

System information

Fedora 35, Intel GPU

Issue description

Backtrace:

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha3.official (256069eaf00be2340259f896695014d92b1e22ed)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x42750) [0x7f0ad9e01750] (??:0)
[2] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x3eae085] (??:0)
[3] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40a3874] (??:0)
[4] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40a4d51] (??:0)
[5] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40b499c] (??:0)
[6] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x292e1b8] (??:0)
[7] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x2a542b8] (??:0)
[8] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x1bb68d6] (??:0)
[9] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x407c85b] (??:0)
[10] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40a4d14] (??:0)
[11] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40b4832] (??:0)
[12] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x403e51d] (??:0)
[13] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x16f97be] (??:0)
[14] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x15ec158] (??:0)
[15] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40465f8] (??:0)
[16] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x3ef7a1a] (??:0)
[17] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x16f96ea] (??:0)
[18] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x15ec158] (??:0)
[19] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40465f8] (??:0)
[20] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x3ed0c44] (??:0)
[21] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x4537005] (??:0)
[22] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x40aa007] (??:0)
[23] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0x298792b] (??:0)
[24] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0xdea8e6] (??:0)
[25] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0xd8cf61] (??:0)
[26] /lib64/libc.so.6(+0x2d560) [0x7f0ad9dec560] (??:0)
[27] /lib64/libc.so.6(__libc_start_main+0x7c) [0x7f0ad9dec60c] (??:0)
[28] /Depot/Applications/Godot/Godot_v4.0-alpha3_linux.64() [0xda685e] (??:0)
-- END OF BACKTRACE --
================================================================

Steps to reproduce

It's very hard for me to isolate what triggered this. I am just trying to convert a game from Godot 3.x to 4.0 and tackling issues one by one. At one point Godot just starting crashing every time.

By the way, it seems like there are no debug symbols in the Godot alpha builds.

Minimal reproduction project

Bugsquad edit: MRP in #58468 (comment)

@Calinou
Copy link
Member

Calinou commented Feb 23, 2022

@tliron Please upload a minimal reproduction project to make this easier to troubleshoot.

By the way, it seems like there are no debug symbols in the Godot alpha builds.

This is intended to decrease binary size. Distributing separate debug symbols files (or builds with debug symbols) is planned, but it will take a while to happen.

In the meantime, you can compile Godot from source to get an useful crash backtrace.

@tliron
Copy link
Author

tliron commented Feb 23, 2022

I cannot upload anything minimal, as stated.

Where do I get Godot 4.0 source to compile? I can't find any 4.0 tags or branches on github.

@Calinou
Copy link
Member

Calinou commented Feb 23, 2022

I cannot upload anything minimal, as stated.

Unfortunately, it's unlikely we can do anything about this crash, even with a backtrace. You can still post a backtrace, but I doubt anyone will be able to fix this without access to a minimal reproduction project.

Where do I get Godot 4.0 source to compile? I can't find any 4.0 tags or branches on github.

The master branch represent the current state of 4.0 development 🙂

@tliron
Copy link
Author

tliron commented Feb 23, 2022

Thanks! Let's keep this issue open, I will try to debug it in C++.

@tliron
Copy link
Author

tliron commented Feb 23, 2022

Here is the backtrace with symbols:

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha.custom_build (b28a83ef3d819785c42ce92679cd988c7002114a)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x42750) [0x7f77c49c3750] (??:0)
[2] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x41d22f5] (/Depot/Build/godot/core/variant/callable.cpp:100)
[3] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43da144] (/Depot/Build/godot/core/object/message_queue.cpp:185)
[4] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43dc065] (/Depot/Build/godot/core/object/message_queue.cpp:136)
[5] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43dc25c] (/Depot/Build/godot/core/object/message_queue.cpp:44)
[6] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x292e658] (/Depot/Build/godot/./core/variant/variant.h:266)
[7] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x2a4c511] (/Depot/Build/godot/scene/gui/button.cpp:377)
[8] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x1b3c48b] (/Depot/Build/godot/./core/templates/cowdata.h:386)
[9] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x1b3c78f] (/Depot/Build/godot/./core/templates/cowdata.h:82 (discriminator 2))
[10] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x441446b] (/Depot/Build/godot/core/string/print_string.cpp:83)
[11] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43dc001] (/Depot/Build/godot/./core/templates/cowdata.h:386)
[12] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43dc114] (/Depot/Build/godot/core/object/message_queue.cpp:44)
[13] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43ddb65] (/Depot/Build/godot/./core/variant/variant.h:205)
[14] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43f1350] (/Depot/Build/godot/./core/object/method_bind.h:176 (discriminator 4))
[15] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x15844ce] (/Depot/Build/godot/modules/gdscript/gdscript_vm.cpp:1628 (discriminator 1))
[16] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x1476b08] (/Depot/Build/godot/modules/gdscript/gdscript.cpp:1528)
[17] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43de16f] (/Depot/Build/godot/core/object/object.cpp:811)
[18] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x421726c] (/Depot/Build/godot/core/variant/variant_call.cpp:1021 (discriminator 6))
[19] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x1584543] (/Depot/Build/godot/./core/variant/variant.h:266)
[20] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x1476b08] (/Depot/Build/godot/modules/gdscript/gdscript.cpp:1528)
[21] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43de16f] (/Depot/Build/godot/core/object/object.cpp:811)
[22] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x41d2026] (/Depot/Build/godot/core/variant/callable.cpp:62)
[23] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43d98c5] (/Depot/Build/godot/core/object/message_queue.cpp:259)
[24] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x43d9bcc] (/Depot/Build/godot/core/object/message_queue.cpp:306)
[25] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0x29a3cfd] (/Depot/Build/godot/scene/main/scene_tree.cpp:461)
[26] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0xa80157] (/Depot/Build/godot/main/main.cpp:2690)
[27] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0xa562a9] (/Depot/Build/godot/platform/linuxbsd/os_linuxbsd.cpp:356)
[28] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0xa4ae15] (/Depot/Build/godot/platform/linuxbsd/godot_linuxbsd.cpp:58)
[29] /lib64/libc.so.6(+0x2d560) [0x7f77c49ae560] (??:0)
[30] /lib64/libc.so.6(__libc_start_main+0x7c) [0x7f77c49ae60c] (??:0)
[31] /Depot/Build/godot/bin/godot.linuxbsd.opt.tools.64() [0xa54f45] (??:?)
-- END OF BACKTRACE --
================================================================

@akien-mga
Copy link
Member

The backtrace is a bit weird, scene/gui/button.cpp:377 is not an actual statement that would call into variant.h. Maybe there's a bug in the crash hander, could you try to run it through gdb to have more details:

$ gdb bin/godot.linuxbsd.opt.tools.64
> run -e --path /path/to/game
> bt

@tliron
Copy link
Author

tliron commented Feb 23, 2022

Is there a way to disable the crash handler? Because under gdb I got the exact same signal 11 and printed backtrace, with no way to use bt.

@Calinou
Copy link
Member

Calinou commented Feb 23, 2022

Is there a way to disable the crash handler? Because under gdb I got the exact same signal 11 and printed backtrace, with no way to use bt.

You can start Godot with the --disable-crash-handler command line argument.

@tliron
Copy link
Author

tliron commented Feb 23, 2022

Nevermind, didn't need to disable it:

Thread 1 "godot.linuxbsd." received signal SIGSEGV, Segmentation fault.
Callable::get_object (this=this@entry=0x7fffe9492020) at core/variant/callable.cpp:100
100			return ObjectDB::get_instance(custom->get_object());
(gdb) bt
#0  Callable::get_object (this=this@entry=0x7fffe9492020) at core/variant/callable.cpp:100
#1  0x00000000043da144 in MessageQueue::statistics (this=0x754ba80) at core/object/message_queue.cpp:183
#2  0x00000000043dc065 in MessageQueue::push_callable (this=0x754ba80, p_callable=..., p_args=0x7fffffffc460, p_argcount=0, p_show_error=<optimized out>)
    at core/object/message_queue.cpp:135
#3  0x00000000043dc25c in MessageQueue::push_call (p_show_error=false, p_argcount=0, p_args=0x7fffffffc460, p_method=..., p_id=..., this=0x754ba80)
    at core/object/message_queue.cpp:44
#4  MessageQueue::push_call (this=0x754ba80, p_id=..., p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...)
    at core/object/message_queue.cpp:59
#5  0x000000000292e658 in CanvasItem::update (this=this@entry=0xeaaffb0) at scene/main/canvas_item.cpp:368
#6  0x0000000002a4c511 in Button::set_text (this=this@entry=0xeaaffb0, p_text=...) at scene/gui/button.cpp:374
#7  0x0000000001b3c48b in EditorLog::LogFilter::set_message_count (p_count=<optimized out>, this=<optimized out>) at editor/editor_log.h:99
#8  EditorLog::_process_message (this=0xea9fe90, p_msg=..., p_type=<optimized out>) at editor/editor_log.cpp:193
#9  0x0000000001b3c78f in EditorLog::add_message (this=0xea9fe90, p_msg=..., p_type=EditorLog::MSG_TYPE_STD) at editor/editor_log.cpp:205
#10 0x000000000441446b in __print_line (p_string=...) at core/string/print_string.cpp:82
#11 0x00000000043dc001 in MessageQueue::push_callable (this=0x754ba80, p_callable=..., p_args=0x7fffffffc928, p_argcount=1, p_show_error=<optimized out>)
    at core/object/message_queue.cpp:134
#12 0x00000000043dc114 in MessageQueue::push_call (this=0x754ba80, p_id=..., p_method=..., p_args=p_args@entry=0x7fffffffc928, p_argcount=p_argcount@entry=1, 
    p_show_error=p_show_error@entry=true) at core/object/message_queue.cpp:44
#13 0x00000000043ddb65 in Object::_call_deferred_bind (this=0x9b04c00, p_args=0x7fffffffc920, p_argcount=2, r_error=...) at core/object/object.h:652
#14 0x00000000043f1350 in MethodBindVarArg<Object>::call (this=<optimized out>, p_object=<optimized out>, p_args=<optimized out>, p_arg_count=<optimized out>, r_error=...)
    at ./core/object/method_bind.h:175
#15 0x00000000015844ce in GDScriptFunction::call (this=0x16e89940, p_instance=<optimized out>, p_args=<optimized out>, p_argcount=<optimized out>, r_err=..., p_state=<optimized out>)
    at modules/gdscript/gdscript_vm.cpp:1628
#16 0x0000000001476b08 in GDScriptInstance::call (this=<optimized out>, p_method=..., p_args=<optimized out>, p_argcount=<optimized out>, r_error=...)
    at modules/gdscript/gdscript.cpp:1528
#17 0x00000000043de16f in Object::call (this=0x9b04c00, p_method=..., p_args=0x7fffffffce40, p_argcount=1, r_error=...) at core/object/object.cpp:811
#18 0x000000000421726c in Variant::call (this=0x7fffffffcd50, p_method=..., p_args=<optimized out>, p_argcount=1, r_ret=..., r_error=...) at core/variant/variant_call.cpp:1021
#19 0x0000000001584543 in GDScriptFunction::call (this=0x16e8a0f0, p_instance=<optimized out>, p_args=<optimized out>, p_argcount=<optimized out>, r_err=..., p_state=<optimized out>)
    at modules/gdscript/gdscript_vm.cpp:1539
#20 0x0000000001476b08 in GDScriptInstance::call (this=<optimized out>, p_method=..., p_args=<optimized out>, p_argcount=<optimized out>, r_error=...)
    at modules/gdscript/gdscript.cpp:1528
#21 0x00000000043de16f in Object::call (this=0x9b04c00, p_method=..., p_args=0x7fffffffd240, p_argcount=1, r_error=...) at core/object/object.cpp:811
#22 0x00000000041d2026 in Callable::call (this=this@entry=0x7fffe9891f50, p_arguments=p_arguments@entry=0x7fffffffd240, p_argcount=p_argcount@entry=1, r_return_value=..., 
--Type <RET> for more, q to quit, c to continue without paging--
    =...) at core/variant/callable.cpp:62
#23 0x00000000043d98c5 in MessageQueue::_call_function (this=<optimized out>, p_callable=..., p_args=<optimized out>, p_argcount=1, p_show_error=<optimized out>) at core/object/message_queue.cpp:258
#24 0x00000000043d9bcc in MessageQueue::flush (this=0x754ba80) at core/object/message_queue.cpp:304
#25 0x00000000029a3cfd in SceneTree::process (this=0x8f29ac0, p_time=0.15000000000000013) at scene/main/scene_tree.cpp:460
#26 0x0000000000a80157 in Main::iteration () at main/main.cpp:2687
#27 0x0000000000a562a9 in OS_LinuxBSD::run (this=this@entry=0x7fffffffd620) at platform/linuxbsd/os_linuxbsd.cpp:356
#28 0x0000000000a4ae15 in main (argc=4, argv=0x7fffffffda48) at platform/linuxbsd/godot_linuxbsd.cpp:58

@tliron
Copy link
Author

tliron commented Feb 24, 2022

A little bit of digging (let me know if you want more, this is easily reproducible for me).

Also, I might be zeroing in on something small and reproducible for you. The NPE happens in a @tool object, more specifically in a @tool than inherits another @tool (this worked fine in Godot 3.x).

(gdb) p this
$1 = (const Callable * const) 0x7fffe9492020
(gdb) p this.custom
$2 = (CallableCustom *) 0x16b6000875
(gdb) p this.custom.referenced
Cannot access memory at address 0x16b6000881

@tliron
Copy link
Author

tliron commented Feb 24, 2022

Good-ish news -- I have isolated the one file that causes the crash. Here's a project:

crash.zip

@akien-mga akien-mga added this to the 4.0 milestone Feb 25, 2022
@akien-mga
Copy link
Member

I can reproduce the crash with that project, though to be clear this happens when editing the "Variant Index" exported property in the Inspector specifically.

It triggers an infinite loop of script errors. The error is also reported when opening the editor before any crash (probably because this code is called in _ready too):

SCRIPT ERROR: Invalid get index '0' (on base: 'Array[Node]').
          at: show_variant_only (res://child.gd:36)

That code is indeed wrong, if there are no children, it's bound to fail:

func show_variant_only():
        var children = get_children()
        var v = children[variant_index] if variant_index != -1 else null

I'm not sure why this method is called ad lib, but that's likely why it crashes in the end.

SCRIPT ERROR: Invalid get index '0' (on base: 'Array[Node]').
          at: show_variant_only (res://child.gd:36)
SCRIPT ERROR: Invalid get index '0' (on base: 'Array[Node]').
          at: show_variant_only (res://child.gd:36)
Failed method: Label::_update_minimum_size
Failed method: Button::_update_callback
 
Thread 1 "godot-git" received signal SIGSEGV, Segmentation fault.
Callable::get_object (this=0x7ffff5585020) at core/variant/callable.cpp:100
100                     return ObjectDB::get_instance(custom->get_object());

(gdb) bt
#0  Callable::get_object (this=0x7ffff5585020) at core/variant/callable.cpp:100
#1  0x0000000009742444 in MessageQueue::statistics (this=0xa4df9e0) at core/object/message_queue.cpp:183
#2  0x00000000097420f0 in MessageQueue::push_callable (this=0xa4df9e0, p_callable=..., p_args=0x7fffffffbec0, p_argcount=0, p_show_error=false) at core/object/message_queue.cpp:135
#3  0x000000000974111e in MessageQueue::push_call (this=0xa4df9e0, p_id=..., p_method=..., p_args=0x7fffffffbec0, p_argcount=0, p_show_error=false) at core/object/message_queue.cpp:44
#4  0x0000000009741212 in MessageQueue::push_call (this=0xa4df9e0, p_id=..., p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...)
    at core/object/message_queue.cpp:59
#5  0x0000000009741f2e in MessageQueue::push_call (this=0xa4df9e0, p_object=0x118d0f10, p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...)
    at core/object/message_queue.cpp:117
#6  0x0000000007b8892b in CanvasItem::update (this=0x118d0f10) at scene/main/canvas_item.cpp:368
#7  0x0000000007cc326a in Button::set_text (this=0x118d0f10, p_text=...) at scene/gui/button.cpp:374
#8  0x0000000006efd09e in EditorLog::LogFilter::set_message_count (this=0x10aa1c80, p_count=2) at editor/editor_log.h:99
#9  0x0000000006ef90c0 in EditorLog::_process_message (this=0x118c0df0, p_msg=..., p_type=EditorLog::MSG_TYPE_STD) at editor/editor_log.cpp:193
#10 0x0000000006ef918d in EditorLog::add_message (this=0x118c0df0, p_msg=..., p_type=EditorLog::MSG_TYPE_STD) at editor/editor_log.cpp:205
#11 0x0000000006f40aeb in EditorNode::_print_handler (p_this=0xc611010, p_string=..., p_error=false) at editor/editor_node.cpp:5737
#12 0x000000000977b58b in __print_line (p_string=...) at core/string/print_string.cpp:82
#13 0x00000000097420ab in MessageQueue::push_callable (this=0xa4df9e0, p_callable=..., p_args=0x7fffffffc430, p_argcount=0, p_show_error=false) at core/object/message_queue.cpp:134
#14 0x000000000974111e in MessageQueue::push_call (this=0xa4df9e0, p_id=..., p_method=..., p_args=0x7fffffffc430, p_argcount=0, p_show_error=false) at core/object/message_queue.cpp:44
#15 0x0000000009741212 in MessageQueue::push_call (this=0xa4df9e0, p_id=..., p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...)
    at core/object/message_queue.cpp:59
#16 0x0000000009741f2e in MessageQueue::push_call (this=0xa4df9e0, p_object=0x19bb0f20, p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...)
    at core/object/message_queue.cpp:117
#17 0x0000000007d335f7 in Control::update_minimum_size (this=0x19bb0f20) at scene/gui/control.cpp:2924
#18 0x0000000007dfad69 in Label::set_text (this=0x19bb0f20, p_string=...) at scene/gui/label.cpp:639
#19 0x00000000070d7c73 in EditorToaster::_popup_str (this=0x107b0de0, p_message=..., p_severity=EditorToaster::SEVERITY_ERROR, p_tooltip=...) at editor/editor_toaster.cpp:433
#20 0x00000000070dd738 in call_with_variant_args_helper<__UnexistingClass, String, EditorToaster::Severity, String, 0ul, 1ul, 2ul> (p_instance=0x107b0de0, p_method=
    (void (__UnexistingClass::*)(__UnexistingClass * const, String, EditorToaster::Severity, String)) 0x70d76a0 <EditorToaster::_popup_str(String, EditorToaster::Severity, String)>, p_args=0x7fffffffc8b0, 
    r_error=...) at ./core/variant/binder_common.h:232
#21 0x00000000070dd3c0 in call_with_variant_args_dv<__UnexistingClass, String, EditorToaster::Severity, String> (p_instance=0x107b0de0, p_method=
--Type <RET> for more, q to quit, c to continue without paging--
    (void (__UnexistingClass::*)(__UnexistingClass * const, String, EditorToaster::Severity, String)) 0x70d76a0 <EditorToaster::_popup_str(String, EditorToaster::Severity, String)>, p_args=0x7fffffffcb40, 
    p_argcount=3, r_error=..., default_values=...) at ./core/variant/binder_common.h:379
#22 0x00000000070dc29c in MethodBindT<String, EditorToaster::Severity, String>::call (this=0xeb68f70, p_object=0x107b0de0, p_args=0x7fffffffcb40, p_arg_count=3, r_error=...) at ./core/object/method_bind.h:280
#23 0x000000000974a64a in Object::call (this=0x107b0de0, p_method=..., p_args=0x7fffffffcb40, p_argcount=3, r_error=...) at core/object/object.cpp:832
#24 0x00000000094bb474 in Callable::call (this=0x7ffff5984ed8, p_arguments=0x7fffffffcb40, p_argcount=3, r_return_value=..., r_call_error=...) at core/variant/callable.cpp:62
#25 0x00000000097431bf in MessageQueue::_call_function (this=0xa4df9e0, p_callable=..., p_args=0x7ffff5984ef0, p_argcount=3, p_show_error=false) at core/object/message_queue.cpp:258
#26 0x00000000097434c7 in MessageQueue::flush (this=0xa4df9e0) at core/object/message_queue.cpp:304
#27 0x0000000007bfc572 in SceneTree::physics_process (this=0xb749ba0, p_time=0.016666666666666666) at scene/main/scene_tree.cpp:426
#28 0x0000000005611c60 in Main::iteration () at main/main.cpp:2657
#29 0x00000000055cbc07 in OS_LinuxBSD::run (this=0x7fffffffd1b0) at platform/linuxbsd/os_linuxbsd.cpp:356
#30 0x00000000055c7f5c in main (argc=2, argv=0x7fffffffd6f8) at platform/linuxbsd/godot_linuxbsd.cpp:58

@akien-mga akien-mga changed the title Godot 4.0 alpha 3 crash Crash when setting exported variable with setter with deferred call to a method with a script error Feb 25, 2022
@tliron
Copy link
Author

tliron commented Feb 25, 2022

This code went through a lot of iterations to work in 3.x. :) I won't be surprised if it doesn't work in 4.0. (It's been very useful for me, by the way. It allows me to select different "variations" during design time while also supporting them in runtime. Maybe I'll write a blog post about it someday.)

However, I'm sure we all agree that we don't want Godot to crash in such situation, right? ;) It seems like you have what you need to debug this, but please let me know if I can assist in any way. I do have a much bigger project that uses this GDScript code.

@akien-mga
Copy link
Member

akien-mga commented Feb 25, 2022

Yes the crash should still be looked into and solved.

But for your use case specifically fixing the bugs in your script should also fix the crash. E.g. by preventing using an invalid index:

func show_variant_only():
	var children = get_children()
	if children.size() <= variant_index: return
	var v = children[variant_index] if variant_index != -1 else null

Same in select_variant. Though it's a sign of a design issue in that code if variant_index can be not -1 yet bigger than the size of what it's meant to index.

@tliron
Copy link
Author

tliron commented Feb 25, 2022

Interesting, I think this is a change from 3.x, because this code worked there -- I think it would return null if out of bounds. Anyway, I'm sure my code could be better. :)

@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 27, 2023
@akien-mga
Copy link
Member

Still reproducible in latest master branch (9ab388c).

@akien-mga akien-mga removed this from the 4.1 milestone Jun 23, 2023
@akien-mga akien-mga added this to the 4.2 milestone Jun 23, 2023
@YuriSizov YuriSizov modified the milestones: 4.2, 4.3 Nov 14, 2023
@KoBeWi KoBeWi removed this from the 4.3 milestone Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants