godot: Possible regression with validated calls?

Godot version

4.2-dev (2 versions, see below)

System information

Windows 10

Issue description

Our godot-rust CI has started failing with recent Godot master versions; there were two events. I did a bisect-style mass test run to find where exactly the behavior changed.

  1. https://github.com/godotengine/godot/pull/79893, commit 4a7d49a89a381f78f19d0b989c5cb5b500f098c9, CI run This one made a particular test fail, but seems relatively deterministic. The PR looks GDScript-focused at first, but changes the way how calls work.

  2. https://github.com/godotengine/godot/pull/82794, commit a6a2d0d1599835364cdf5f912f98d87c5317dd05, CI run This one fails even before actual tests are run.

It’s of course possible that we are doing something wrong, i.e. godot-rust contained a bug that was already present and only manifested now. If that’s the case, any ideas in which direction to look? Have others encountered similar issues?

For 2., we also have a stacktrace in the CI job. Click to expand...
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.dev.custom_build (a6a2d0d1599835364cdf5f912f98d87c5317dd05)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x43090) [0x7f4f798db090] (??:0)
[2] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x4d30ce) [0x7f4f760c30ce] (??:0)
[3] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x4c16ec) [0x7f4f760b16ec] (??:0)
[4] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x52be3) [0x7f4f75c42be3] (??:0)
[5] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x1913c4) [0x7f4f75d813c4] (??:0)
[6] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x525c1) [0x7f4f75c425c1] (??:0)
[7] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0xca9c5) [0x7f4f75cba9c5] (??:0)
[8] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x41702e) [0x7f4f7600702e] (??:0)
[9] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x42c56b) [0x7f4f7601c56b] (??:0)
[10] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x402f8e) [0x7f4f75ff2f8e] (??:0)
[11] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x6d996) [0x7f4f75c5d996] (??:0)
[12] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x1c0d88) [0x7f4f75db0d88] (??:0)
[13] /home/runner/work/godot4-mass-tester/godot4-mass-tester/gdext/itest/godot/../../target/debug/libitest.so(+0x80930) [0x7f4f75c70930] (??:0)
[14] GDExtensionMethodBind::ptrcall(Object*, void const**, void*) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/extension/gdextension.cpp:255)
[15] GDExtensionMethodBind::validated_call(Object*, Variant const**, Variant*) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/extension/gdextension.cpp:242)
[16] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript_vm.cpp:1956)
[17] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript.cpp:1849)
[18] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/object/object.cpp:752)
[19] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/callable.cpp:62)
[20] _VariantCall::func_Callable_call(Variant*, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/variant_call.cpp:1025)
[21] /home/runner/work/_temp/godot_bin/godot.linuxbsd.editor.dev.x86_64(+0x6c64dbc) [0x556be5b52dbc] (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/variant_call.cpp:2038)
[22] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/variant_call.cpp:1182)
[23] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript_vm.cpp:1668)
[24] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript.cpp:1849)
[25] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/object/object.cpp:752)
[26] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/variant_call.cpp:1168)
[27] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript_vm.cpp:1668)
[28] GDScriptFunctionState::resume(Variant const&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript_function.cpp:216)
[29] GDScriptFunctionState::_signal_callback(Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/modules/gdscript/gdscript_function.cpp:157)
[30] MethodBindVarArgTR<GDScriptFunctionState, Variant>::call(Object*, Variant const**, int, Callable::CallError&) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/./core/object/method_bind.h:265 (discriminator 4))
[31] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/object/object.cpp:774)
[32] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/callable.cpp:62)
[33] CallableCustomBind::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/callable_bind.cpp:145)
[34] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/variant/callable.cpp:50)
[35] Object::emit_signalp(StringName const&, Variant const**, int) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/core/object/object.cpp:1128)
[36] Error Object::emit_signal<>(StringName const&) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/./core/object/object.h:920)
[37] SceneTree::physics_process(double) (/home/runner/work/godot4-mass-tester/godot4-mass-tester/scene/main/scene_tree.cpp:466)
[38] Main::iteration() (/home/runner/work/godot4-mass-tester/godot4-mass-tester/main/main.cpp:3550)
[39] OS_LinuxBSD::run() (/home/runner/work/godot4-mass-tester/godot4-mass-tester/platform/linuxbsd/os_linuxbsd.cpp:933)
[40] /home/runner/work/_temp/godot_bin/godot.linuxbsd.editor.dev.x86_64(main+0x193) [0x556be190a78c] (/home/runner/work/godot4-mass-tester/godot4-mass-tester/platform/linuxbsd/godot_linuxbsd.cpp:76)
[41] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f4f798bc083] (??:0)
[42] /home/runner/work/_temp/godot_bin/godot.linuxbsd.editor.dev.x86_64(_start+0x2e) [0x556be190a53e] (??:?)
-- END OF BACKTRACE --
================================================================
/home/runner/work/_temp/ab405092-db9f-4f07-939c-f211055b54cf.sh: line 8:  3196 Aborted                 (core dumped) $GODOT4_BIN --headless 2>&1

Steps to reproduce

Build Godot 4a7d49a89a381f78f19d0b989c5cb5b500f098c9 Build godot-rust/gdext master (a92164bb3a98108b95506f80769408583421e6dc) Run integration test suite

Minimal reproduction project

N/A

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 3
  • Comments: 16 (15 by maintainers)

Most upvoted comments

I added some asserts to check for null pointers (https://github.com/lilizoey/gdextension/tree/feature/ptrcall-errors), and it appears that we’re getting null pointers as return pointers in some cases

~/D/r/g/i/godot (feature/ptrcall-errors) [SIGABRT]> RUST_BACKTRACE=1 ~/Programs/Godot/godot.linuxbsd.editor.dev.x86_64 --headless
Initialize GDExtension API for Rust: Godot Engine v4.2.dev.custom_build
Godot Engine v4.2.dev.custom_build.691634969 - https://godotengine.org

Executing special case tests...
ERROR: Rust function panicked in file /home/<username>/Development/rust/gdextension/godot-core/src/builtin/meta/signature.rs at line 443. Context: get_viewport
   at: <function unset> (godot-core/src/lib.rs:154)
ERROR: Panic msg:  get_viewport: ret pointer is null
   at: <function unset> (godot-core/src/lib.rs:102)
WARNING: The "push_unhandled_input()" method is deprecated, use "push_input()" instead.
     at: push_unhandled_input (scene/main/viewport.cpp:3201)
thread '<unnamed>' panicked at /home/<username>/Development/rust/gdextension/godot-core/src/builtin/meta/signature.rs:443:5:
input_event: ret pointer is null
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2e5a9dd6c9eaa42f0684b4b760bd68fc27cbe51b/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/2e5a9dd6c9eaa42f0684b4b760bd68fc27cbe51b/library/core/src/panicking.rs:72:14
   2: godot_core::builtin::meta::signature::ptrcall_return
             at /home/<username>/Development/rust/gdextension/godot-core/src/builtin/meta/signature.rs:443:5
   3: <(R,P0,P1,P2) as godot_core::builtin::meta::signature::PtrcallSignatureTuple>::in_ptrcall
             at /home/<username>/Development/rust/gdextension/godot-core/src/builtin/meta/signature.rs:274:17
   4: <itest::object_tests::virtual_methods_test::CollisionObject2DTest as godot_core::obj::traits::cap::ImplementsGodotVirtual>::__virtual_call::function
             at /home/<username>/Development/rust/gdextension/itest/rust/src/object_tests/virtual_methods_test.rs:468:1
   5: _ZN17CollisionObject2D28_gdvirtual__input_event_callILb0EEEbP8Viewport3RefI10InputEventEi
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/2d/collision_object_2d.h:112:2
   6: _ZN17CollisionObject2D17_input_event_callEP8ViewportRK3RefI10InputEventEi
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/2d/collision_object_2d.cpp:516:2
   7: _ZN8Viewport16_process_pickingEv
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/main/viewport.cpp:851:30
   8: _Z29call_with_variant_args_helperI17__UnexistingClassJEJEEvPT_MS1_FvDpT0_EPPK7VariantRN8Callable9CallErrorE13IndexSequenceIJXspT1_EEE
             at /home/runner/work/godot4-nightly/godot4-nightly/./core/variant/binder_common.h:303:25
   9: _Z25call_with_variant_args_dvI17__UnexistingClassJEEvPT_MS1_FvDpT0_EPPK7VariantiRN8Callable9CallErrorERK6VectorIS7_E
             at /home/runner/work/godot4-nightly/godot4-nightly/./core/variant/binder_common.h:450:31
  10: _ZNK11MethodBindTIJEE4callEP6ObjectPPK7VariantiRN8Callable9CallErrorE
             at /home/runner/work/godot4-nightly/godot4-nightly/./core/object/method_bind.h:335:28
  11: _ZN6Object5callpERK10StringNamePPK7VariantiRN8Callable9CallErrorE
             at /home/runner/work/godot4-nightly/godot4-nightly/core/object/object.cpp:774:21
  12: _ZN9SceneTree17call_group_flagspEjRK10StringNameS2_PPK7Varianti
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/main/scene_tree.cpp:298:23
  13: _ZN9SceneTree10call_groupIJEEEvRK10StringNameS3_DpT_
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/main/scene_tree.h:299:20
  14: _ZN9SceneTree15physics_processEd
             at /home/runner/work/godot4-nightly/godot4-nightly/scene/main/scene_tree.cpp:466:12
  15: _ZN4Main9iterationEv
             at /home/runner/work/godot4-nightly/godot4-nightly/main/main.cpp:3550:60
  16: _ZN11OS_LinuxBSD3runEv
             at /home/runner/work/godot4-nightly/godot4-nightly/platform/linuxbsd/os_linuxbsd.cpp:933:22
  17: main
             at /home/runner/work/godot4-nightly/godot4-nightly/platform/linuxbsd/godot_linuxbsd.cpp:74:9
  18: <unknown>
  19: __libc_start_main
  20: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
fish: Job 1, 'RUST_BACKTRACE=1 ~/Programs/God…' terminated by signal SIGABRT (Abort)

In fact i think methods that return Variant gets a null pointer as the return pointer. Im not entirely sure how the godot code works here, but i think the return pointer might not get initialized in validated_call when doing a pointer call and the return type is Variant.

@Bromeon @lilizoey Can you see if PR https://github.com/godotengine/godot/pull/83054 fixes the problem for you? I’m not sure it’s the right way to fix it (even if it fixes the problem), but it’ll show us which branch the problem is happening on