Skip to content

Global godot-type variable cause crash and load gdextension failed #1449

Open
@pupil1337

Description

@pupil1337

Godot version

4.3.dev(11d3768)

godot-cpp version

4.3.dev(e23b117)

System information

win11

Issue description

This issue have existed for a long time, The reproduction steps are the same as this comment: #358 (comment).

String s; // crashes
class SomeClass {
    static Dictionary d; // crashes
    static Node *singleton; // fine, pointer doesn't call a constructor
};

This issue is quite tricky, as it is caused by godot load gdextension .dll and initializate GDExtensionInterface
order.
Do need to solve this problem?

Steps to reproduce

// world.h

const String level0 = "res://level/level0.tscn"; // load gdextension.dll will call String constructor, but this time gdextension function didnt initialized

class World : public Node {
	GDCLASS(World, Node)
	static void _bind_methods() {}
};

Define a global variable String, open godot.exe timeline:

  1. start open godot.exe
  2. godot.exe: Load gdextension.dll -> dll: global variable Construct -> dll: call String construct GDExtensionInterface(not initialzed and will Crash)
  3. godot.exe: initialize gdextension.dll GDExtensionInterface

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions