Skip to content

Macros "_THREAD_SAFE_XXX" in " include/godot_cpp/core/mutex_lock.hpp" are not work correctly in godot-cpp. #2020

Closed

Description

@Daylily-Zeleen

Godot version

4.7-stable

godot-cpp version

ba0edfe

System information

Windows 10, i7-8750h

Issue description

Macros "_THREAD_SAFE_XXX" in " include/godot_cpp/core/mutex_lock.hpp" use godot::Mutex without memnew() or Ref<T>, it will lead to the crash CRASH_NOW_MSG("BUG: Godot Object created without binding callbacks. Did you forget to use memnew()?");

It seems that "include/godot_cpp/core/mutex_lock.hpp" is simply migrated from godot source, we should do some change by using std::mutex or godot::Ref<godot::Mutex>, or consider the possibility of using some godot object without memnew().

Steps to reproduce

Just use _THREAD_SAFE_CLASS_ in any class and try to instantiate it.

// register_types.cpp
...
#include <godot_cpp/core/mutex_lock.hpp>

class MutexTest {
    _THREAD_SAFE_CLASS_

public: 
    void test() {
        ...
    }
};

...

void initialize_gdextension_types(ModuleInitializationLevel p_level)
{
	MutexTest  test; // Crash
	...
}

Minimal reproduction project

N/A

Activity

  1. added
    bug
    on Jul 25, 2026
  2. added this to the 10.x milestone on Jul 25, 2026
  3. dsnopek commented on Jul 25, 2026

    @dsnopek
    Collaborator

    Thanks! I just posted PR #2026 which fixes this issue in my testing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions