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

Godot editor crashes when hot reloading gdext library with custom resources #582

Open
tomdedecker opened this issue Jan 27, 2024 · 6 comments
Labels
bug c: engine Godot classes (nodes, resources, ...)

Comments

@tomdedecker
Copy link

tomdedecker commented Jan 27, 2024

A few days ago I started experimenting with custom resources for my gdext project and noticed that I started getting editor crashes every time (or at least most of the time) when I made a change to a node using a custom resource. Fast forward a bit and I was able to make a minimal reproducible example using a single node and resource. You can find it here or in the attached zip file.

gdext-reload-crash-master.zip

The scenario is as follows:

  1. Download the project
  2. Compile the rust code (cargo build inside /rust)
  3. Open the project in the Godot editor
  4. Run the game
  5. Open rust/src/node.rs
  6. Uncomment the second print line in ready()
  7. Build the module again
  8. Re-run the game in the editor

At this point the editor typically crashes for me, producing one of 3 stack traces (as far as I encountered), which I've also added to the root of the repository. Two of these crashed in Godot's source code and the other inside the gdext project. I considered opening an issue with Godot's as I assumed that this might be a problem on their end, but I wanted to check here first.

I haven't tested this on any other platforms yet, but I can consistently reproduce it on my Linux (x86-64) install with Godot 4.2.1.

If you need any other info or if this is an issue I should check with Godot itself, please let me know.

Kind regards,
Tom

@lilizoey
Copy link
Member

Does this still happen if the resource is declared as

#[export]
resource: Option<Gd<MyResource>>,

?

@tomdedecker
Copy link
Author

So far I haven't been able to reproduce it when wrapped in an Option, but even after making it required again I'm still having a hard time reproducing it. I'll experiment with it a bit and see if I can get it to crash when the resource is optional.

Are resources expected to always be optional or is this just to help diagnose the issue?

@tomdedecker
Copy link
Author

I was able to reproduce the crash in my actual project when I made my custom resource optional, but after restarting the editor I have yet to experience a new crash. Assuming the first crash was due to a limitation of the current hot reloading system, making the resource optional might indeed fix the issue. I'll keep you posted if I encounter it again.

@Bromeon
Copy link
Member

Bromeon commented Feb 2, 2024

@tomdedecker any updates yet? 🙂

@tomdedecker
Copy link
Author

As far as I can tell the issue remains as before. As long as the resource is not marked as optional, the editor seems to frequently crash when hot reloading. Marking the resource as optional and restarting the editor seems to avoid/bypass the issue, making subsequent hot reloads work as expected. I'm not sure if this is an issue on Godot's end or in gdext, but if there's any extra information I can provide I'd be happy to help.

@Bromeon
Copy link
Member

Bromeon commented Mar 2, 2024

Might also be fixed by #636.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: engine Godot classes (nodes, resources, ...)
Projects
None yet
Development

No branches or pull requests

3 participants