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 loading resource on init with API 4.3 #912

Open
gg-yb opened this issue Oct 7, 2024 · 7 comments
Open

Crash when loading resource on init with API 4.3 #912

gg-yb opened this issue Oct 7, 2024 · 7 comments
Labels

Comments

@gg-yb
Copy link
Contributor

gg-yb commented Oct 7, 2024

Minimum Example Project

https://github.com/gg-yb/gdext-crash-example

How to reproduce

In the attached example, build the extension using cargo build.

Open the project with Godot 4.3 (make sure there is no .godot folder in the godot/ directory)

user@host:~$ $GODOT4_BIN -e /tmp/foo/godot/project.godot
Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org
Vulkan 1.3.242 - Forward+ - Using Device #1: NVIDIA - NVIDIA RTX A3000 12GB Laptop GPU

Initialize godot-rust (API v4.3.stable.official, runtime v4.3.stable.official)

No crash is observed. Close Godot.

Notice that the .godot folder was created in the godot/ directory.

Open the project again, again with Godot 4.3.

user@host:~$ $GODOT4_BIN -e /tmp/foo/godot/project.godot
Initialize godot-rust (API v4.3.stable.official, runtime v4.3.stable.official)
Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org
Vulkan 1.3.242 - Forward+ - Using Device #1: NVIDIA - NVIDIA RTX A3000 12GB Laptop GPU

thread '<unnamed>' panicked at /home/###/.cargo/git/checkouts/gdext-76630c89719e160c/8ad9cb0/godot-core/src/obj/raw_gd.rs:433:9:
Class the_extension::MyResource -- null instance; does the class have a Godot creator function?
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x7509bf40c62a - std::backtrace_rs::backtrace::libunwind::trace::hd0d9e4bd21f3ebc9
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7509bf40c62a - std::backtrace_rs::backtrace::trace_unsynchronized::h03dc45ba97e4e000
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7509bf40c62a - std::sys::backtrace::_print_fmt::h41ee95bedacc5db8
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/sys/backtrace.rs:66:9
   3:     0x7509bf40c62a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he860c317670a8ee8
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/sys/backtrace.rs:39:26
   4:     0x7509bf42dda3 - core::fmt::rt::Argument::fmt::h917a511a383df218
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/fmt/rt.rs:177:76
   5:     0x7509bf42dda3 - core::fmt::write::h85942acfab9fbb8e
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/fmt/mod.rs:1186:21
   6:     0x7509bf409f93 - std::io::Write::write_fmt::h02454f05ec1899d2
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/io/mod.rs:1839:15
   7:     0x7509bf40c472 - std::sys::backtrace::BacktraceLock::print::h60a3ebc4bc614975
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/sys/backtrace.rs:42:9
   8:     0x7509bf40d7f5 - std::panicking::default_hook::{{closure}}::h14eeb32e0ebecbed
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/panicking.rs:268:22
   9:     0x7509bf40d624 - std::panicking::default_hook::h9fd211a2ee9131e9
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/panicking.rs:295:9
  10:     0x7509bf40def8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h15aac826966489d1
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/alloc/src/boxed.rs:2468:9
  11:     0x7509bf40def8 - std::panicking::rust_panic_with_hook::h292eb934d0cf1505
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/panicking.rs:809:13
  12:     0x7509bf40dc86 - std::panicking::begin_panic_handler::{{closure}}::hed6c4fa0eff7f2ee
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/panicking.rs:667:13
  13:     0x7509bf40cb09 - std::sys::backtrace::__rust_end_short_backtrace::he0671e483c6dc999
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/sys/backtrace.rs:170:18
  14:     0x7509bf40d94c - rust_begin_unwind
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/std/src/panicking.rs:665:5
  15:     0x7509bf42bb4d - core::panicking::panic_nounwind_fmt::runtime::h406be1279524466c
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/panicking.rs:112:18
  16:     0x7509bf42bb4d - core::panicking::panic_nounwind_fmt::hbd69c707d8b71076
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/panicking.rs:122:5
  17:     0x7509bf42bbe2 - core::panicking::panic_nounwind::h06630d12fa9c1739
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/panicking.rs:221:5
  18:     0x7509bf42bda6 - core::panicking::panic_cannot_unwind::hf2ccf89b2179eefd
                               at /rustc/06bb8364aaffefb0ce67e5f5445e66ec99c1f66e/library/core/src/panicking.rs:310:5
  19:     0x7509bf1f653e - godot_core::registry::callbacks::create::h1942740b05a0e0f5
                               at /home/###/.cargo/git/checkouts/gdext-76630c89719e160c/8ad9cb0/godot-core/src/registry/callbacks.rs:22:1
  20:          0x4330df6 - <unknown>
  21:          0x12c0583 - <unknown>
  22:          0x12fa7af - <unknown>
  23:          0x12fd245 - <unknown>
  24:          0x480008d - <unknown>
  25:          0x4314724 - <unknown>
  26:          0x23b61cc - <unknown>
  27:           0x5272d0 - <unknown>
  28:           0x4202a2 - <unknown>
  29:     0x7509cf629d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  30:     0x7509cf629e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  31:           0x43d44a - <unknown>
  32:                0x0 - <unknown>
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

The project crashes on this attempt, and any further attempt, unless the .godot folder is deleted.

This behavior is new to API 4.3, and this pattern has been used by us for some time, see observations below.

Code Excerpt

lib.rs:

use godot::{
    classes::{Control, IControl},
    prelude::*,
    tools,
};

struct Ext;

#[gdextension]
unsafe impl ExtensionLibrary for Ext {}

#[derive(GodotClass)]
#[class(base=Control)]
pub struct MyControl {
    base: Base<Control>,
}

#[godot_api]
impl IControl for MyControl {
    fn init(base: Base<Self::Base>) -> Self {
        let mf = tools::try_load::<MyResource>("res://MyResource.tres");
        mf.unwrap().bind();
        Self { base }
    }
}

#[derive(GodotClass)]
#[class(base=Resource, init)]
pub struct MyResource;

Use Case

The loaded resource is used to configure auxilliary behavior of, among others, MyControl in the real project.

Observations

Does not occur unless API 4.3 is selected (i.e. no features, or features = ["api-4-3"] in Cargo.toml), so:

API 4.2, Godot 4.2: No crashes

API 4.2, Godot 4.3: No crashes

API 4.3, Godot 4.3: CRASHES

@Bromeon Bromeon added the bug label Oct 9, 2024
@rieval
Copy link

rieval commented Oct 25, 2024

Any updates on this issue? I'm happy to help explore possible solutions.

@Bromeon
Copy link
Member

Bromeon commented Oct 25, 2024

Not from my side -- if you have time to investigate, that would be appreciated! 😊

@gg-yb
Copy link
Contributor Author

gg-yb commented Dec 16, 2024

Some investigation seems to point to the generation of documentation generation, where Godot attempts to instantiate my custom resource class to obtain default properties.

Backtrace with a debug build of Godot 4.3:

Initialize godot-rust (API v4.3.stable.official, runtime v4.3.stable.custom_build)
Godot Engine v4.3.stable.custom_build.77dcf97d8 (2024-08-14 23:00:16 UTC) - https://godotengine.org
OpenGL API 3.3.0 NVIDIA 535.183.01 - Compatibility - Using Device: NVIDIA - NVIDIA RTX A3000 12GB Laptop GPU

thread '<unnamed>' panicked at <snip>/gdext/godot-core/src/obj/raw_gd.rs:435:9:
Class <snip>::MyResource -- null instance; does the class have a Godot creator function?
stack backtrace:
   0:     0x775ba6e4053a - std::backtrace_rs::backtrace::libunwind::trace::h6f2b574f2ffb5eeb
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x775ba6e4053a - std::backtrace_rs::backtrace::trace_unsynchronized::hb4661274c5f328e7
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x775ba6e4053a - std::sys::backtrace::_print_fmt::h773b68c115ef71bb
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:66:9
   3:     0x775ba6e4053a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfb283d37bfab5ead
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:39:26
   4:     0x775ba6e68bb3 - core::fmt::rt::Argument::fmt::h5e5bc3c775602426
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/fmt/rt.rs:177:76
   5:     0x775ba6e68bb3 - core::fmt::write::h8aec3611be69c225
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/fmt/mod.rs:1437:21
   6:     0x775ba6e3c9a3 - std::io::Write::write_fmt::h7a6143ccddf039a2
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/io/mod.rs:1887:15
   7:     0x775ba6e40382 - std::sys::backtrace::BacktraceLock::print::h67bdc04e67783ae5
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:42:9
   8:     0x775ba6e416ee - std::panicking::default_hook::{{closure}}::h59807bbef61a9ae9
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:284:22
   9:     0x775ba6e41533 - std::panicking::default_hook::h52623d20c6055942
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:311:9
  10:     0x775ba6e41f08 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb876c61e217f565c
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/alloc/src/boxed.rs:1984:9
  11:     0x775ba6e41f08 - std::panicking::rust_panic_with_hook::hb96af4fc25ad4934
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:825:13
  12:     0x775ba6e41bba - std::panicking::begin_panic_handler::{{closure}}::h9d740b0b773941bc
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:690:13
  13:     0x775ba6e40a19 - std::sys::backtrace::__rust_end_short_backtrace::h57185422cbbdf99c
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:168:18
  14:     0x775ba6e4184d - rust_begin_unwind
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:681:5
  15:     0x775ba6e664c0 - core::panicking::panic_fmt::h56dedefee5d65cc3
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/panicking.rs:75:14
  16:     0x775ba62923a7 - godot_core::obj::raw_gd::RawGd<T>::resolve_instance_ptr::h53e274b90a14a67c
                               at <snip>/gdext/godot-core/src/obj/raw_gd.rs:435:9
  17:     0x775ba628619e - godot_core::obj::raw_gd::RawGd<T>::storage_unbounded::h9916602c4d917336
                               at <snip>/gdext/godot-core/src/obj/raw_gd.rs:415:27
  18:     0x775ba629651a - godot_core::obj::raw_gd::RawGd<T>::storage::hf2329658beae666e
                               at <snip>/gdext/godot-core/src/obj/raw_gd.rs:391:18
  19:     0x775ba62957db - godot_core::obj::raw_gd::RawGd<T>::bind::h642a61cb63c19d60
                               at <snip>/gdext/godot-core/src/obj/raw_gd.rs:372:27
  20:     0x775ba6371ee6 - godot_core::obj::gd::Gd<T>::bind::h6ccd6b796cec29ff
                               at <snip>/gdext/godot-core/src/obj/gd.rs:172:9
  <snip>
  25:     0x775ba64b8588 - std::sync::once_lock::OnceLock<T>::get_or_init::{{closure}}::hb24d7785b7731846
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once_lock.rs:304:50
  26:     0x775ba64b6f39 - std::sync::once_lock::OnceLock<T>::initialize::{{closure}}::h287456fd346d902e
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once_lock.rs:512:19
  27:     0x775ba639df0e - std::sync::once::Once::call_once_force::{{closure}}::h20938e06ff9e9216
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once.rs:217:40
  28:     0x775ba6e46544 - std::sys::sync::once::futex::Once::call::h472b085b9d91eceb
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/sync/once/futex.rs:176:21
  29:     0x775ba639c3a5 - std::sync::once::Once::call_once_force::h254af58a6df89cde
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once.rs:217:9
  30:     0x775ba64b6bfb - std::sync::once_lock::OnceLock<T>::initialize::heb34aff3662800bd
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once_lock.rs:511:9
  31:     0x775ba64b9a4a - std::sync::once_lock::OnceLock<T>::get_or_try_init::h953181b79f1135d9
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once_lock.rs:390:9
  32:     0x775ba64b7d5e - std::sync::once_lock::OnceLock<T>::get_or_init::h1814b7459ec71667
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/once_lock.rs:304:15
  <snip>
  38:     0x775ba6555b45 - <MyGodotClass as godot_core::gen::classes::control::re_export::IControl>::init::h6ff519ffd7e1ccae
                               at <snip>
  39:     0x775ba6556ffd - <MyGodotClass as godot_core::obj::traits::cap::GodotDefault>::__godot_user_init::hec717bc800ecd939
                               at <snip>
  40:     0x775ba644f8cf - core::ops::function::FnOnce::call_once::hbf8bf3b369521b6a
                               at <snip>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  41:     0x775ba64d03b9 - godot_core::registry::callbacks::create_rust_part_for_existing_godot_part::hb73dd4eff8ec77b3
                               at <snip>/gdext/godot-core/src/registry/callbacks.rs:69:25
  42:     0x775ba64c831a - godot_core::registry::callbacks::create_custom::ha910979204f2b999
                               at <snip>/gdext/godot-core/src/registry/callbacks.rs:45:5
  43:     0x775ba64d339e - godot_core::registry::callbacks::create::hc459d7c2328bb3f7
                               at <snip>/gdext/godot-core/src/registry/callbacks.rs:25:5
  44:     0x5bdcd950f47a - _ZN7ClassDB21_instantiate_internalERK10StringNameb
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:532:46
  45:     0x5bdcd950f631 - _ZN7ClassDB27instantiate_no_placeholdersERK10StringName
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:554:30
  46:     0x5bdcd9518cac - _ZN7ClassDB32class_get_default_property_valueERK10StringNameS2_Pb
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:2032:44
  47:     0x5bdcd5af39ec - get_documentation_default_value
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:380:60
  48:     0x5bdcd5af4c3d - _ZN8DocTools8generateE8BitFieldINS_13GenerateFlagsEE
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:539:53
  49:     0x5bdcd5b6e084 - _ZN10EditorHelp12generate_docEb
                               at <snip>/Tools/godot/godot/editor/editor_help.cpp:2957:16
  50:     0x5bdcd53c2eb9 - _Z29call_with_variant_args_staticIJbEJLm0EEEvPFvDpT_EPPK7VariantRN8Callable9CallErrorE13IndexSequenceIJXspT0_EEE
                               at <snip>/Tools/godot/godot/./core/variant/binder_common.h:778:12
  51:     0x5bdcd53c2cc2 - _Z33call_with_variant_args_static_retIJbEEvPFvDpT_EPPK7VariantiRS4_RN8Callable9CallErrorE
                               at <snip>/Tools/godot/godot/./core/variant/binder_common.h:847:37
  52:     0x5bdcd53c294b - _ZNK36CallableCustomStaticMethodPointerRetIvJbEE4callEPPK7VariantiRS1_RN8Callable9CallErrorE
                               at <snip>/Tools/godot/godot/./core/object/callable_method_pointer.h:309:36
  53:     0x5bdcd916bc6c - _ZNK8Callable5callpEPPK7VariantiRS0_RNS_9CallErrorE
                               at <snip>/Tools/godot/godot/core/variant/callable.cpp:57:15
  54:     0x5bdcd95296f2 - _ZN9CallQueue14_call_functionERK8CallablePK7Variantib
                               at <snip>/Tools/godot/godot/core/object/message_queue.cpp:220:18
  55:     0x5bdcd9529afc - _ZN9CallQueue5flushEv
                               at <snip>/Tools/godot/godot/core/object/message_queue.cpp:268:20
  56:     0x5bdcd6dff139 - _ZN9SceneTree15physics_processEd
                               at <snip>/Tools/godot/godot/scene/main/scene_tree.cpp:492:38
  57:     0x5bdcd3f29a6d - _ZN4Main9iterationEv
                               at <snip>/Tools/godot/godot/main/main.cpp:4070:60
  58:     0x5bdcd3e5e766 - _ZN11OS_LinuxBSD3runEv
                               at <snip>/Tools/godot/godot/platform/linuxbsd/os_linuxbsd.cpp:962:22
  59:     0x5bdcd3e56539 - main
                               at <snip>/Tools/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:85:9
  60:     0x775bb7029d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  61:     0x775bb7029e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  62:     0x5bdcd3e562e5 - _start
  63:                0x0 - <unknown>
thread '<unnamed>' panicked at library/core/src/panicking.rs:218:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x775ba6e4053a - std::backtrace_rs::backtrace::libunwind::trace::h6f2b574f2ffb5eeb
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x775ba6e4053a - std::backtrace_rs::backtrace::trace_unsynchronized::hb4661274c5f328e7
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x775ba6e4053a - std::sys::backtrace::_print_fmt::h773b68c115ef71bb
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:66:9
   3:     0x775ba6e4053a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfb283d37bfab5ead
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:39:26
   4:     0x775ba6e68bb3 - core::fmt::rt::Argument::fmt::h5e5bc3c775602426
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/fmt/rt.rs:177:76
   5:     0x775ba6e68bb3 - core::fmt::write::h8aec3611be69c225
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/fmt/mod.rs:1437:21
   6:     0x775ba6e3c9a3 - std::io::Write::write_fmt::h7a6143ccddf039a2
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/io/mod.rs:1887:15
   7:     0x775ba6e40382 - std::sys::backtrace::BacktraceLock::print::h67bdc04e67783ae5
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:42:9
   8:     0x775ba6e416ee - std::panicking::default_hook::{{closure}}::h59807bbef61a9ae9
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:284:22
   9:     0x775ba6e41533 - std::panicking::default_hook::h52623d20c6055942
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:311:9
  10:     0x775ba6e41f08 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb876c61e217f565c
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/alloc/src/boxed.rs:1984:9
  11:     0x775ba6e41f08 - std::panicking::rust_panic_with_hook::hb96af4fc25ad4934
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:825:13
  12:     0x775ba6e41b86 - std::panicking::begin_panic_handler::{{closure}}::h9d740b0b773941bc
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:683:13
  13:     0x775ba6e40a19 - std::sys::backtrace::__rust_end_short_backtrace::h57185422cbbdf99c
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/sys/backtrace.rs:168:18
  14:     0x775ba6e4184d - rust_begin_unwind
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/std/src/panicking.rs:681:5
  15:     0x775ba6e664fd - core::panicking::panic_nounwind_fmt::runtime::ha71aa9c8b70d93b6
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/panicking.rs:117:22
  16:     0x775ba6e664fd - core::panicking::panic_nounwind_fmt::h5d705fcc627e7f73
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/intrinsics/mod.rs:3840:9
  17:     0x775ba6e66592 - core::panicking::panic_nounwind::h7f25b13f44dcba3b
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/panicking.rs:218:5
  18:     0x775ba6e66756 - core::panicking::panic_cannot_unwind::h1df10292a1f2217f
                               at /rustc/33c245b9e98bc91e18ea1c5033824f4c6f92766f/library/core/src/panicking.rs:307:5
  19:     0x775ba64d33ae - godot_core::registry::callbacks::create::hc459d7c2328bb3f7
                               at <snip>/gdext/godot-core/src/registry/callbacks.rs:22:1
  20:     0x5bdcd950f47a - _ZN7ClassDB21_instantiate_internalERK10StringNameb
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:532:46
  21:     0x5bdcd950f631 - _ZN7ClassDB27instantiate_no_placeholdersERK10StringName
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:554:30
  22:     0x5bdcd9518cac - _ZN7ClassDB32class_get_default_property_valueERK10StringNameS2_Pb
                               at <snip>/Tools/godot/godot/core/object/class_db.cpp:2032:44
  23:     0x5bdcd5af39ec - get_documentation_default_value
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:380:60
  24:     0x5bdcd5af4c3d - _ZN8DocTools8generateE8BitFieldINS_13GenerateFlagsEE
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:539:53
  25:     0x5bdcd5b6e084 - _ZN10EditorHelp12generate_docEb
                               at <snip>/Tools/godot/godot/editor/editor_help.cpp:2957:16
  26:     0x5bdcd53c2eb9 - _Z29call_with_variant_args_staticIJbEJLm0EEEvPFvDpT_EPPK7VariantRN8Callable9CallErrorE13IndexSequenceIJXspT0_EEE
                               at <snip>/Tools/godot/godot/./core/variant/binder_common.h:778:12
  27:     0x5bdcd53c2cc2 - _Z33call_with_variant_args_static_retIJbEEvPFvDpT_EPPK7VariantiRS4_RN8Callable9CallErrorE
                               at <snip>/Tools/godot/godot/./core/variant/binder_common.h:847:37
  28:     0x5bdcd53c294b - _ZNK36CallableCustomStaticMethodPointerRetIvJbEE4callEPPK7VariantiRS1_RN8Callable9CallErrorE
                               at <snip>/Tools/godot/godot/./core/object/callable_method_pointer.h:309:36
  29:     0x5bdcd916bc6c - _ZNK8Callable5callpEPPK7VariantiRS0_RNS_9CallErrorE
                               at <snip>/Tools/godot/godot/core/variant/callable.cpp:57:15
  30:     0x5bdcd95296f2 - _ZN9CallQueue14_call_functionERK8CallablePK7Variantib
                               at <snip>/Tools/godot/godot/core/object/message_queue.cpp:220:18
  31:     0x5bdcd9529afc - _ZN9CallQueue5flushEv
                               at <snip>/Tools/godot/godot/core/object/message_queue.cpp:268:20
  32:     0x5bdcd6dff139 - _ZN9SceneTree15physics_processEd
                               at <snip>/Tools/godot/godot/scene/main/scene_tree.cpp:492:38
  33:     0x5bdcd3f29a6d - _ZN4Main9iterationEv
                               at <snip>/Tools/godot/godot/main/main.cpp:4070:60
  34:     0x5bdcd3e5e766 - _ZN11OS_LinuxBSD3runEv
                               at <snip>/Tools/godot/godot/platform/linuxbsd/os_linuxbsd.cpp:962:22
  35:     0x5bdcd3e56539 - main
                               at <snip>/Tools/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:85:9
  36:     0x775bb7029d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  37:     0x775bb7029e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  38:     0x5bdcd3e562e5 - _start
  39:                0x0 - <unknown>
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

@gg-yb
Copy link
Contributor Author

gg-yb commented Dec 16, 2024

It seems that MyResource is created by PlaceholderExtensionInstance::placeholder_class_create_instance. This might violate gdext's invariants if this is later returned from load...

@gg-yb
Copy link
Contributor Author

gg-yb commented Dec 16, 2024

Making MyResource a tool class fixes this. Apparently this is needed in some cases due to doc generation?

@Bromeon
Copy link
Member

Bromeon commented Dec 16, 2024

Which doc generation do you mean?

The one where RustDoc is translated to Godot needs to be enabled with register-docs feature. Do you have this? If yes, what happens without?

@gg-yb
Copy link
Contributor Author

gg-yb commented Dec 16, 2024

The doc generation I deduce from this part of the trace:

  23:     0x5bdcd5af39ec - get_documentation_default_value
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:380:60
  24:     0x5bdcd5af4c3d - _ZN8DocTools8generateE8BitFieldINS_13GenerateFlagsEE
                               at <snip>/Tools/godot/godot/editor/doc_tools.cpp:539:53
  25:     0x5bdcd5b6e084 - _ZN10EditorHelp12generate_docEb
                               at <snip>/Tools/godot/godot/editor/editor_help.cpp:2957:16

Interestingly enough, I do not have the feature set. I guess the generation on the gdext side is not affected, Godot itself seems to try to create an instance with a placeholder extension in order to derive default values? Not quite sure, as I can only guess from looking at the control flow.

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

No branches or pull requests

3 participants