Skip to content

Mac Editor Crash When Exposing Resource in Inspector from GDExtension  #1432

Open
@kromenak

Description

Godot version

4.2.1.stable

godot-cpp version

godot-4.2.1-stable

System information

macOS 14.4.1 - Vulkan (Mobile) - integrated Apple M3 Max - Apple M3 Max (16 Threads)

Issue description

I am writing some game code in C++ using GDExtension. As part of this, I have a custom manager class (set up as an Autoload) that exposes a custom Resource in the Inspector.

On Mac, every time I recompile the dylib and the editor does the hot reload process, the editor crashes with this stack trace:
CrashReport.txt

The crash report appears to point to destructing a Resource inside my Autoload manager class as the culprit for the crash. In my testing, I found that if this field is set to an object (either on-disk or embedded in the manager scene), I get the crash. If the field is null/empty, I do not get a crash. If I remove the _bind_methods code to expose the field in the Inspector, I do not get a crash.

I see this behavior when compiling on Mac via Xcode or CLion. I haven't yet seen this issue on Windows.

I believe the method I'm using to expose the Resource is correct, but there isn't a huge amount of GDExtension documentation, so I'm not 100% sure. My expectation would be that the current code doesn't crash the editor when hot reloading.

Steps to reproduce

In the provided project, I believe you can reproduce the crash using these steps:

  1. Open the provided C++ project (in "Cpp" folder) in either CLion or Xcode on Mac. It is configured using CMake. Build in debug mode.
  2. Open the Godot project in the Res folder. Note that there is a "SceneManager.tscn" with a GameSettings Resource that is embedded in the scene directly. Also note that this SceneManager scene is hooked up as an Autoload in the project. You should also see a log output about the Resource.
  3. Make a small change to the C++ code and rebuild the library in debug mode.
  4. Focus the Godot Editor, which will then try to hot reload the GDExtension's updated dylib. However, the Editor will beach-ball and then crash.

Minimal reproduction project

ResourceBug.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions