Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variant::iter_get on empty Array crashes in release, but no errors reported in debug #1652

Open
allenwp opened this issue Nov 25, 2024 · 0 comments

Comments

@allenwp
Copy link
Contributor

allenwp commented Nov 25, 2024

Godot version

v4.3.stable.official [77dcf97d8]

godot-cpp version

4.3 56571dc

System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 980 Ti (NVIDIA; 32.0.15.6603) - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)

Issue description

Calling Variant::iter_get on an empty Array causes this crash, but only in release builds of the godot-cpp GDExtension:

Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org
Vulkan 1.3.289 - Forward Mobile - Using Device #0: NVIDIA - NVIDIA GeForce GTX 980 Ti

ERROR: FATAL: Index p_index = 0 is out of bounds (size() = 0).
   at: get (./core/templates/cowdata.h:205)

I cannot reproduce this release-only behaviour on builds of the Godot editor, so it appears to only behave this way on release builds of GDExtension.

This issue also happens with other types of Array, such as PackedVector4Array. This makes me suspect that this sort of behaviour could exist elsewhere in GDExtension...

Steps to reproduce

Write the following code:

Variant arrayAsVariant = Array();

Variant iterator;
bool iter_valid;
arrayAsVariant.iter_init(iterator, iter_valid);
Variant value = arrayAsVariant.iter_get(iterator, iter_valid);

Compile with scons dev_build=yes and note that there are no issues, warnings, or errors and value is null.

Compile with scons target=template_release and note that the error and crash occur.

Minimal reproduction project

Here is an example GDExtension:
release-only-gdextension-crash.zip

  • Copy over godot-cpp 4.3 branch into godot-cpp folder
  • Run both scons dev_build=yes and scons target=template_release to generate GDExtension DLL files
  • Open the godot project in the demo folder
  • Export both debug and release builds of the game

Here is my compiler info:
Using SCons-detected MSVC version 14.3, arch x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant