Skip to content

ScriptExtension produces missing virtual error on editor run #80275

Description

@voidedWarranties

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Fedora Linux 38 (Workstation Edition) - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (nvidia; 535.54.03) - AMD Ryzen 7 3700X 8-Core Processor (16 Threads)

Issue description

When starting a project that utilizes ScriptExtension with the editor, the following error occurs:

E 0:00:00:0703   _gdvirtual__get_language_call: Required virtual method ScriptExtension::_get_language must be overridden before calling.
  <C++ Source>   ./core/object/script_language_extension.h:106 @ _gdvirtual__get_language_call()

even though the method is implemented and registered.

From my debugging, I believe this is the condition under which the error happens:

  1. Project starts from editor.
  2. Godot attempts to load a script.
  3. When the Script is constructed, Wrapped's constructor creates the Godot-side object, postinitialize_handler is called from the Godot side, and NOTIFICATION_POSTINITIALIZE is fired.
  4. Script's notification handler fires, which attempts to call get_language.
  5. The virtual call attempts to find the Script's corresponding extension. It cannot find it, so the call fails and the error is printed.
  6. postinitialize_handler is called on the GDExtension side and the Script's extension is finally set.
  7. Virtual calls outside of postinitialize_handler are successful.

I'm not 100% sure this is correct, but it seems fairly likely.

Steps to reproduce

  1. Install any extension that utilizes ScriptExtension.
  2. Create a script.
  3. Run the project from the editor.

Minimal reproduction project

MRP_ScriptExtension_virtual.zip

I've attached binaries from my implementation as I don't think a different extension will produce a different result. You can verify that get_language is implemented here.

Usage:

  1. Unzip the archive and start the editor.
  2. The editor will crash on import due to an unrelated issue.
  3. Open the editor again.
  4. Start the main scene.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions