godotengine / godotengine/godot-cpp

Script freezes Godot on load due to name collision

Open
#172 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

**Branch Nativescript 1.1**
Given the following code:
```
#include "Sprite.hpp"
class Sprite : public godot::Sprite {

GODOT_CLASS(Sprite, godot::Sprite);

public:
static void _register_methods() {};
void _init() {};
};

/* Godot export stuff */
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
godot::Godot::gdnative_terminate(o);
}

extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);

godot::register_class();
}
```
This does not happen if `Sprite` extends something different than `Sprite` (e.g. `Sprite3D`)

It compiles fine, but when loading the `.gdns` that uses `Sprite` the game freezes in some kind of loop.
Not sure this is relevant, but here's a trace from SIGINT I sent:

```
String::copy_from (this=0x7fffffffa678, p_cstr=0x5555596bce2b "NativeScript") at core/ustring.cpp:145
145 for (int i = 0; i < len + 1; i++) {
(gdb) bt
#0 String::copy_from (this=0x7fffffffa678, p_cstr=0x5555596bce2b "NativeScript") at core/ustring.cpp:145
#1 0x000055555936fda5 in String::String (this=0x7fffffffa678, p_str=0x5555596bce2b "NativeScript") at core/ustring.cpp:1588
#2 0x000055555637a6ab in NativeScript::get_class_static () at modules/gdnative/nativescript/nativescript.h:102
#3 NativeScript::_get_class_namev (this=0x55555e6eadf0) at modules/gdnative/nativescript/nativescript.h:102
#4 0x00005555591a0637 in Object::_postinitialize (this=0x55555e6eadf0) at core/object.cpp:394
#5 0x00005555591b03d3 in postinitialize_handler (p_object=0x55555e6eadf0) at core/object.cpp:1923
#6 0x00005555563730db in _post_initialize (p_obj=0x55555e6eadf0) at ./core/os/memory.h:93
#7 NativeScriptLanguage::create_script (this=0x55555b3af130) at modules/gdnative/nativescript/nativescript.cpp:1068
#8 0x000055555636de00 in NativeScript::get_base_script (this=0x55555e6eafe0) at modules/gdnative/nativescript/nativescript.cpp:152
#9 0x00005555564e0361 in GDScriptParser::_get_function_signature (this=0x7fffffffcc00, p_base_type=..., p_function=..., r_return_type=..., r_arg_types=...,
r_default_arg_count=@0x7fffffffad4c: 0, r_static=@0x7fffffffae48: false, r_vararg=@0x7fffffffad47: false) at modules/gdscript/gdscript_parser.cpp:6238
#10 0x00005555564e40ea in GDScriptParser::_reduce_function_call_type (this=0x7fffffffcc00, p_call=0x55555e6e0bd0) at modules/gdscript/gdscript_parser.cpp:6486
#11 0x00005555564da50d in GDScriptParser::_reduce_node_type (this=0x7fffffffcc00, p_node=0x55555e6e0bd0) at modules/gdscript/gdscript_parser.cpp:5753
#12 0x00005555564eb3eb in GDScriptParser::_check_class_level_types (this=0x7fffffffcc00, p_class=0x55555b9da250) at modules/gdscript/gdscript_parser.cpp:6976
#13 0x00005555564f5aa8 in GDScriptParser::_parse (this=0x7fffffffcc00, p_base_path=...) at modules/gdscript/gdscript_parser.cpp:7614
#14 0x00005555564f5cbc in GDScriptParser::parse (this=0x7fffffffcc00, p_code=..., p_base_path=..., p_just_validate=false, p_self_path=..., p_for_completion=false, r_safe_lines=0x0)
at modules/gdscript/gdscript_parser.cpp:7658
#15 0x00005555563e83c0 in GDScript::reload (this=0x55555ac67660, p_keep_state=false) at modules/gdscript/gdscript.cpp:573
#16 0x00005555563f2f84 in ResourceFormatLoaderGDScript::load (this=0x55555bf49c20, p_path=..., p_original_path=..., r_error=0x0) at modules/gdscript/gdscript.cpp:1954
#17 0x00005555594acd41 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:173
#18 0x00005555594ad1de in ResourceLoader::load (p_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:218
#19 0x00005555584d2935 in ResourceInteractiveLoaderText::poll (this=0x55555c1b2c80) at scene/resources/scene_format_text.cpp:432
#20 0x00005555594acb05 in ResourceFormatLoader::load (this=0x55555b9df810, p_path=..., p_original_path=..., r_error=0x0) at core/io/resource_loader.cpp:138
#21 0x00005555594acd41 in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:173
#22 0x00005555594ad1de in ResourceLoader::load (p_path=..., p_type_hint=..., p_no_cache=false, r_error=0x0) at core/io/resource_loader.cpp:218
#23 0x0000555556241a2f in Main::start () at main/main.cpp:1673
#24 0x00005555562180bc in main (argc=3, argv=0x7fffffffde48) at platform/x11/godot_x11.cpp:54
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.