Description
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