Skip to content

Crash on hot reload when binding gd pointers #984

Open
@theKidOfArcrania

Description

@theKidOfArcrania

There is an issue in hot reloading where godot would segfault if you bind to self node when it gets hot reloaded.

Minimum example:

use godot::prelude::*;

#[repr(C)]
#[derive(GodotClass)]
#[class(init, base = Node, tool)]
pub struct MyNode {
    test: u64,
    base: Base<Node>,
}

#[godot_api]
impl INode for MyNode {
    fn ready(&mut self) {
        let call = Callable::from_local_fn(
            "test",
            |_| {
                Ok(Variant::nil())
            },
        ).bindv(&Array::from_iter([self.to_gd().to_variant()]));
        self.base_mut().connect(c"tree_entered", &call);
    }
}

struct Test;

#[gdextension]
unsafe impl ExtensionLibrary for Test {}

When a scene with this node is loaded in godot, and then you rebuild (and thus trigger a hot reload), and then attempt to close that scene, it will then cause godot to crash entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions