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

Accessing keys() dict of an enum defined in a singleton crashes app #70495

Closed
jmb462 opened this issue Dec 23, 2022 · 14 comments · Fixed by #70246 or #70613
Closed

Accessing keys() dict of an enum defined in a singleton crashes app #70495

jmb462 opened this issue Dec 23, 2022 · 14 comments · Fixed by #70246 or #70613

Comments

@jmb462
Copy link
Contributor

jmb462 commented Dec 23, 2022

Godot version

beta10

System information

Windows10

Issue description

With beta10, when an enum is defined in an autoloaded script, calling the keys() method on the enum crash the app.

Works well if the enum is not defined in a singleton.
Worked well in beta9

Steps to reproduce

1°) Define an enum in a script and make it as an autoloaded script in your project.
2°) Try to access this enum keys() method from another script
Should work in beta9 but crash in beta10

Minimal reproduction project

global_enum_bug.zip

@akien-mga
Copy link
Member

CC @adamscott @rune-scape

@jtnicholl
Copy link
Contributor

jtnicholl commented Dec 24, 2022

I can confirm this, I ran into it in one of my own projects, wasn't sure what in my project was triggering it. It also happens if the enum is accessed via the class name.
From a git bisect, it was caused by #70220. That PR also causes my project to print a bunch of errors on startup:

ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)
ERROR: Condition "!method" is true. Returning: 0
   at: get_builtin_method_argument_count (core/variant/variant_call.cpp:1265)
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)
ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)
ERROR: Condition "!method" is true. Returning: 0
   at: get_builtin_method_argument_count (core/variant/variant_call.cpp:1265)
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)
ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)
ERROR: Condition "!method" is true. Returning: 0
   at: get_builtin_method_argument_count (core/variant/variant_call.cpp:1265)
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)

I'd open a separate issue for these errors if I could figure out an MRP.

@Lippanon
Copy link

Lippanon commented Dec 24, 2022

I've also bisected a crash in my main project caused by #70220, likely related. Backtrace dump:

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.0.beta.custom_build (edfa1e8665564da54bd0090283e5b6c671b70983)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[0] ???
[1] ???
[2] GDScriptFunction::call (c:\-redacted-\godot-4.x\modules\gdscript\gdscript_vm.cpp:1998)
[3] GDScriptInstance::callp (c:\-redacted-\godot-4.x\modules\gdscript\gdscript.cpp:1830)
[4] Node::_notification (c:\-redacted-\godot-4.x\scene\main\node.cpp:154)
[5] CanvasItem::_notificationv (c:\-redacted-\godot-4.x\scene\main\canvas_item.h:45)
[6] Control::_notificationv (c:\-redacted-\godot-4.x\scene\gui\control.h:47)
[7] Object::notification (c:\-redacted-\godot-4.x\core\object\object.cpp:792)
[8] Node::_propagate_ready (c:\-redacted-\godot-4.x\scene\main\node.cpp:188)
[9] Node::_propagate_ready (c:\-redacted-\godot-4.x\scene\main\node.cpp:179)
[10] Node::_propagate_ready (c:\-redacted-\godot-4.x\scene\main\node.cpp:179)
[11] Node::_propagate_ready (c:\-redacted-\godot-4.x\scene\main\node.cpp:179)
[12] Node::_propagate_ready (c:\-redacted-\godot-4.x\scene\main\node.cpp:179)
[13] Node::_set_tree (c:\-redacted-\godot-4.x\scene\main\node.cpp:2574)
[14] SceneTree::initialize (c:\-redacted-\godot-4.x\scene\main\scene_tree.cpp:411)
[15] OS_Windows::run (c:\-redacted-\godot-4.x\platform\windows\os_windows.cpp:1273)
[16] widechar_main (c:\-redacted-\godot-4.x\platform\windows\godot_windows.cpp:181)
[17] _main (c:\-redacted-\godot-4.x\platform\windows\godot_windows.cpp:205)[18] main (c:\-redacted-\godot-4.x\platform\windows\godot_windows.cpp:217)
[19] __scrt_common_main_seh (d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)[20] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================

@git2013vb
Copy link

Well.. because I have singleton with enums and I use keys() I can suppose I have the same problem too inv 4.0.beta10.official [d0398f6]

lots of these at start:

   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)
ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)
ERROR: Condition "!method" is true. Returning: 0
   at: get_builtin_method_argument_count (core/variant/variant_call.cpp:1265)
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)
ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)

Thanks

@adamscott
Copy link
Member

CC @anvilfolk, the enum specialist.

@adamscott
Copy link
Member

@akien-mga Fortunately, our PR #70246 fixes this issue.

@dalexeev
Copy link
Member

dalexeev commented Dec 25, 2022

I got the following errors too:

ERROR: Condition "!method" is true. Returning: false
   at: is_builtin_method_vararg (core/variant/variant_call.cpp:1339)
ERROR: Condition "!method" is true. Returning: 0
   at: get_builtin_method_argument_count (core/variant/variant_call.cpp:1265)
ERROR: Condition "!method" is true. Returning: Variant::NIL
   at: get_builtin_method_return_type (core/variant/variant_call.cpp:1318)
ERROR: Condition "!method" is true. Returning: nullptr
   at: get_validated_builtin_method (core/variant/variant_call.cpp:1251)

And sometimes crash (dev_build=true, no strip):

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.beta.custom_build (f382a2b59bb9606f958ccaf7be7ac98f45607c9f)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3bcf0) [0x7f633d03bcf0] (??:0)
-- END OF BACKTRACE --

@anvilfolk
Copy link
Contributor

anvilfolk commented Dec 25, 2022

It would be absolutely excellent if someone could provide an MRP for these ERROR: Condition "!method" is true. errors and link it here. We know there's some serious issues with that right now but it's been hard to pin-point. An MRP would go a long way <3

@dalexeev
Copy link
Member

dalexeev commented Dec 25, 2022

It would be absolutely excellent if someone could provide an MRP

Here's the reason:

extends Node

func _ready() -> void:
    print(MyClass.MyEnum.size())

MRP: issue-70495.zip

EDIT: I fixed get_size() to size(). The errors and crash remained the same.

@anvilfolk
Copy link
Contributor

💯 thank you! Will look into it!! :)

@anvilfolk
Copy link
Contributor

@dalexeev thank you! Found the issue, fixed in #70569 :)

That plus the currently linked PR should fix everything in this thread, I believe!

@dalexeev
Copy link
Member

I think these cases should be added to the tests to reduce the chance of such regressions in the future.

@anvilfolk
Copy link
Contributor

Oh, perfect call, I'll do that now! Thanks for the reminder, I always forget it for myself :) We're slowly building a bigger and bigger test suite that will hopefully catch a whole lot more.

@anvilfolk
Copy link
Contributor

So actually, I just realized this doesn't happen when enums are in the same file, so there's something else happening here that's throwing me for a loop and I want to dig a little more, because I might've fixed a symptom and not a cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
8 participants