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

[4.0] Trying to access enumerators declared in an autoload or class causes silent crash #71199

Closed
TheSecondReal0 opened this issue Jan 11, 2023 · 10 comments
Labels

Comments

@TheSecondReal0
Copy link
Contributor

TheSecondReal0 commented Jan 11, 2023

Godot version

4.0 b10,b11

System information

Windows 10, RTX 2060, Vulkan

Issue description

Cannot access an enumerator statically from a user defined class or from an autoload. Game crashes without error.

Exception thrown at 0x00007FF6CE53AC63 in godot.windows.editor.x86_64.exe: 0xC0000005: Access violation reading location 0x00000039FFFFFFFC.

Stack trace ``` > godot.windows.editor.x86_64.exe!CowData::_ref(const CowData & p_from) Line 405 C++ godot.windows.editor.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 1875 C++ godot.windows.editor.x86_64.exe!GDScriptInstance::get_property_list(List * p_properties) Line 1698 C++ godot.windows.editor.x86_64.exe!Object::get_property_list(List * p_list, bool p_reversed) Line 509 C++ godot.windows.editor.x86_64.exe!Resource::duplicate(bool p_subresources) Line 254 C++ [Inline Frame] godot.windows.editor.x86_64.exe!call_with_variant_args_retc_helper(Resource *) Line 762 C++ godot.windows.editor.x86_64.exe!call_with_variant_args_retc_dv,bool>(Resource * p_instance, Ref(const Resource::*)(bool) p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error, const Vector & default_values) Line 557 C++ godot.windows.editor.x86_64.exe!MethodBindTRC,bool>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 546 C++ godot.windows.editor.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 1673 C++ godot.windows.editor.x86_64.exe!GDScriptInstance::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 1847 C++ godot.windows.editor.x86_64.exe!Object::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 711 C++ godot.windows.editor.x86_64.exe!Variant::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error) Line 1161 C++ godot.windows.editor.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 1551 C++ godot.windows.editor.x86_64.exe!GDScriptInstance::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 1847 C++ godot.windows.editor.x86_64.exe!Object::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 711 C++ godot.windows.editor.x86_64.exe!Variant::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error) Line 1161 C++ godot.windows.editor.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 1551 C++ godot.windows.editor.x86_64.exe!GDScriptInstance::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 1847 C++ godot.windows.editor.x86_64.exe!Object::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 711 C++ godot.windows.editor.x86_64.exe!Variant::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant & r_ret, Callable::CallError & r_error) Line 1161 C++ godot.windows.editor.x86_64.exe!GDScriptFunction::call(GDScriptInstance * p_instance, const Variant * * p_args, int p_argcount, Callable::CallError & r_err, GDScriptFunction::CallState * p_state) Line 1583 C++ godot.windows.editor.x86_64.exe!GDScriptInstance::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 1847 C++ [Inline Frame] godot.windows.editor.x86_64.exe!Node::_gdvirtual__ready_call() Line 242 C++ godot.windows.editor.x86_64.exe!Node::_notification(int p_notification) Line 155 C++ [Inline Frame] godot.windows.editor.x86_64.exe!Node::_notificationv(int) Line 46 C++ [Inline Frame] godot.windows.editor.x86_64.exe!CanvasItem::_notificationv(int) Line 45 C++ godot.windows.editor.x86_64.exe!Node2D::_notificationv(int p_notification, bool p_reversed) Line 37 C++ godot.windows.editor.x86_64.exe!Object::notification(int p_notification, bool p_reversed) Line 792 C++ godot.windows.editor.x86_64.exe!Node::_propagate_ready() Line 189 C++ godot.windows.editor.x86_64.exe!Node::_propagate_ready() Line 179 C++ godot.windows.editor.x86_64.exe!Node::_set_tree(SceneTree * p_tree) Line 2595 C++ godot.windows.editor.x86_64.exe!Node::_add_child_nocheck(Node * p_child, const StringName & p_name) Line 1123 C++ godot.windows.editor.x86_64.exe!Node::add_child(Node * p_child, bool p_force_readable_name, Node::InternalMode p_internal) Line 1139 C++ godot.windows.editor.x86_64.exe!SceneTree::_change_scene(Node * p_to) Line 1120 C++ [Inline Frame] godot.windows.editor.x86_64.exe!call_with_variant_args_helper(EditorNode *) Line 293 C++ godot.windows.editor.x86_64.exe!call_with_variant_args_dv(EditorNode * p_instance, void(EditorNode::*)(Node *) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error, const Vector & default_values) Line 440 C++ godot.windows.editor.x86_64.exe!MethodBindT::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 318 C++ godot.windows.editor.x86_64.exe!Object::callp(const StringName & p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 733 C++ godot.windows.editor.x86_64.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 62 C++ godot.windows.editor.x86_64.exe!MessageQueue::_call_function(const Callable & p_callable, const Variant * p_args, int p_argcount, bool p_show_error) Line 230 C++ godot.windows.editor.x86_64.exe!MessageQueue::flush() Line 292 C++ godot.windows.editor.x86_64.exe!SceneTree::physics_process(double p_time) Line 432 C++ godot.windows.editor.x86_64.exe!Main::iteration() Line 3026 C++ godot.windows.editor.x86_64.exe!OS_Windows::run() Line 1277 C++ godot.windows.editor.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 181 C++ godot.windows.editor.x86_64.exe!_main() Line 205 C++ godot.windows.editor.x86_64.exe!main(int argc, char * * argv) Line 217 C++ ```

Steps to reproduce

Create a class that has an enumerator. Try to access the enumerator statically like this:

print(ClassName.ENUM)

Otherwise, you can create an autoload that has enumerator and try to access it like this:

print(Autoload.ENUM)

Minimal reproduction project

The project prints null for the enum in certain cases, when it should always print the enum like a dictionary. Other variable types work fine, specifically enums don't work in this case.

enum-bug-testing.zip

@adamscott

This comment was marked as resolved.

@TheSecondReal0
Copy link
Contributor Author

TheSecondReal0 commented Jan 11, 2023

Figured out more specifically what was happening, updated the original post and added a minimal reproduction project.

@TheSecondReal0
Copy link
Contributor Author

TheSecondReal0 commented Jan 11, 2023

Turns out it's a much bigger bug than I thought, it happens any time you try to access an enumerator in specific ways. Updated the minimal reproduction project and original post.

@TheSecondReal0 TheSecondReal0 changed the title [4.0] Game crashes without error when run from the editor [4.0] Trying to access enumerators in an autoload or defined class causes silent crash Jan 11, 2023
@TheSecondReal0 TheSecondReal0 changed the title [4.0] Trying to access enumerators in an autoload or defined class causes silent crash [4.0] Trying to access enumerators declared in an autoload or class causes silent crash Jan 11, 2023
@adamscott
Copy link
Member

I just checked and "enumerators" doesn't seem the right term. I suggest to use enum.
https://en.wikipedia.org/wiki/Enumerated_type

@adamscott
Copy link
Member

CC @anvilfolk

@adamscott
Copy link
Member

Could not reproduce on master (f73cb4c).

@anvilfolk
Copy link
Contributor

anvilfolk commented Jan 11, 2023

Can't reproduce using the MRP on Beta10, Beta11 or on master. I wouldn't have been surprised if the problem was here before Beta11 since the enum fixes only came with Beta11.

Tried opening every script & running the project, no errors.

Could there be anything else at all in play here? It's strange that you can reproduce that in B10 and B11 - biiiiig changes happened between those two!

@anvilfolk
Copy link
Contributor

anvilfolk commented Jan 11, 2023

Nevermind, I am silly, I didn't realize the error wouldn't be reported, it would just show up as null. It's working for me on B11 and master. But you're right, enums are borked in B10 :)

Can you double-check with beta11? I'm pretty sure this is just enums not really working before #69590 which came with Beta11 :)

@TheSecondReal0
Copy link
Contributor Author

You're right, thanks for looking. My project was broken in both b10 and b11 so I assumed what was messing up in b10 was messing up in b11.

B11 was crashing because trying to iterate over a const PackedStringArray in an _init() function is broken.

Thank you so much for spending the time looking into this @anvilfolk !

@anvilfolk
Copy link
Contributor

It's a team effort! :) Thanks for reporting! :) Lots of big stuff in flux! I'm hoping your other problems are also already fixed in master. Lots of fixes for regressions introduced recently :)

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

No branches or pull requests

4 participants