godot-rust / godot-rust/gdext

Panic + abort when overriding property list on `MeshLibrary`

Open
#1,668 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.2k
Forks
312
Avg merge
11h 10m
Merged PRs (30d)
10

Description

The following code hard crashes the editor when added to a `GridMap`:
```rust
use godot::{
classes::{IMeshLibrary, MeshLibrary},
prelude::*,
register::info::PropertyInfo,
};

#[derive(GodotClass)]
#[class(base=MeshLibrary, init, tool)]
pub struct CrashingMeshLibrary {
base: Base,
}

#[godot_api]
impl IMeshLibrary for CrashingMeshLibrary {
fn on_get_property_list(&mut self) -> Vec {
vec![]
}
}
```
...but only when it's in a submodule, or something...? This bug is kind of weird and tends to disappear when studied

I can reproduce it with the following project when launching Godot via the command line:
`reset; RUST_BACKTRACE=1 ./Godot /Users/centdemeern1/Documents/GodotProjects/meshlibrary-repro/Godot/project.godot`
[meshlibrary-repro.zip](https://github.com/user-attachments/files/30542329/meshlibrary-repro.zip)

Log and backtrace

```
Initialize godot-rust (API v4.7.stable.official, runtime v4.7.1.stable.official, safeguards strict)
Godot Engine v4.7.1.stable.official.a13da4feb - https://godotengine.org
Metal 4.0 - Forward+ - Using Device #0: Apple - Apple M4 (Apple9)

[backtrace of previous `bind_mut` borrow]
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: std::backtrace_rs::backtrace::trace_unsynchronized::<::create::{closure#0}>
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: ::create
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/backtrace.rs:331:13
3: ::track_mut_borrow
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/mod.rs:175:28
4: as godot_core::storage::instance_storage::Storage>::get_mut
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/single_threaded.rs:78:29
5: >::instance
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/instance_storage.rs:213:60
6: godot_core::registry::callbacks::get_property_list::
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/registry/callbacks.rs:352:20

[panic /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/mod.rs:38]
Gd::bind_mut() failed, already bound; T = meshlibrary_repro::module::crashing_meshlibrary::CrashingMeshLibrary.
Make sure to use `self.base_mut()` instead of `self.to_gd()` when possible.
Details: cannot borrow while accessible mutable borrow exists.

[panic backtrace]
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: std::backtrace_rs::backtrace::trace_unsynchronized::<::create::{closure#0}>
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: ::create
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/backtrace.rs:331:13
3: godot_core::private::set_gdext_hook::::{closure#0}::{closure#0}>::{closure#0}
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/private.rs:310:44
4: core::ops::function::Fn<(&'a std::panic::PanicHookInfo<'b>,), Output = ()> + core::marker::Sync + core::marker::Send> as core::ops::function::Fn<(&std::panic::PanicHookInfo,)>>::call
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/alloc/src/boxed.rs:2289:9
5: std::panicking::panic_with_hook
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:833:13
6: std::panicking::panic_handler::{closure#0}
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:698:13
7: std::sys::backtrace::__rust_end_short_backtrace::
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/sys/backtrace.rs:182:18
8: __rustc::rust_begin_unwind
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:689:5
9: core::panicking::panic_fmt
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/panicking.rs:80:14
10: godot_core::storage::bind_mut_failed::
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/mod.rs:38:5
11: as godot_core::storage::instance_storage::Storage>::get_mut::{closure#0}
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/single_threaded.rs:76:33
12: , alloc::boxed::Box>>::unwrap_or_else::< as godot_core::storage::instance_storage::Storage>::get_mut::{closure#0}>
at /Users/centdemeern1/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:1622:23
13: as godot_core::storage::instance_storage::Storage>::get_mut
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/single_threaded.rs:76:14
14: >::instance
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/storage/instance_storage.rs:213:60
15: godot_core::registry::callbacks::get_property_list::
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/registry/callbacks.rs:352:20

[panic /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/panicking.rs:225] panic in a function that cannot unwind

[panic backtrace]
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: std::backtrace_rs::backtrace::trace_unsynchronized::<::create::{closure#0}>
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: ::create
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/backtrace.rs:331:13
3: godot_core::private::set_gdext_hook::::{closure#0}::{closure#0}>::{closure#0}
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/private.rs:310:44
4: core::ops::function::Fn<(&'a std::panic::PanicHookInfo<'b>,), Output = ()> + core::marker::Sync + core::marker::Send> as core::ops::function::Fn<(&std::panic::PanicHookInfo,)>>::call
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/alloc/src/boxed.rs:2289:9
5: std::panicking::panic_with_hook
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:833:13
6: std::panicking::panic_handler::{closure#0}
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:691:13
7: std::sys::backtrace::__rust_end_short_backtrace::
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/sys/backtrace.rs:182:18
8: __rustc::rust_begin_unwind
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/std/src/panicking.rs:689:5
9: core::panicking::panic_nounwind_fmt::runtime
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/panicking.rs:122:22
10: core::panicking::panic_nounwind_fmt
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/intrinsics/mod.rs:2450:9
11: core::panicking::panic_nounwind
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/panicking.rs:225:5
12: core::panicking::panic_cannot_unwind
at /rustc/8bab26f4f68e0e26f0bb7960be334d5b520ea452/library/core/src/panicking.rs:337:5
13: godot_core::registry::callbacks::get_property_list::
at /Users/centdemeern1/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.5.4/src/registry/callbacks.rs:346:1

thread caused non-unwinding panic. aborting.
zsh: abort RUST_BACKTRACE=1 ./Godot
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the crash with the linked meshlibrary-repro project and the provided Godot command. Inspect the godot_core registry callbacks at callbacks.rs:346-352 and the storage paths shown in the backtrace, especially the mutable borrow handling. Done means overriding MeshLibrary's property list no longer panics and aborts when used from a GridMap.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.