-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
GDScript: Fix some lambda bugs #81605
GDScript: Fix some lambda bugs #81605
Conversation
Thanks for testing and documenting! I also saw some of these and several others. It looks like hot reloading can cause a random effect, depending on how the bytecode length (or something else) changes. In theory this can be dangerous. |
226d4ac
to
295f8e2
Compare
295f8e2
to
d6282cc
Compare
d6282cc
to
b1eb737
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not proficient with the GDScriptCompiler but I tested the changes and confirmed the bug fixes, without visible regression in a project that uses lambdas and awaits them a lot.
So I think we can merge so this gets tested in dev5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great PR from our @dalexeev that pass the test! Thanks for the numerous tests added.
Thanks! |
As stated in #81572,
GDScriptFunction::_get_call_error()
can crash the engine.godot/modules/gdscript/gdscript_vm.cpp
Lines 118 to 121 in 3ed4497
godot/modules/gdscript/gdscript_vm.cpp
Line 1773 in 3ed4497
I decided to check what
err.argument
was equal to, and it turned out to be-1
. This is because lambda captures are hidden arguments of lambda function.godot/modules/gdscript/gdscript_lambda_callable.cpp
Lines 77 to 88 in 3ed4497
If for some reason a capture is invalid (for example, due to a bug in the compiler or if the object has been freed at this point), then this leads to a negative argument index and a crash.
godot/modules/gdscript/gdscript_vm.cpp
Lines 545 to 548 in 3ed4497
godot/modules/gdscript/gdscript_function.h
Lines 109 to 113 in 3ed4497
Callable
call errors #80844.)Status