GDScript: Fix stack manipulation for await
#61003
Merged
+28
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The stack now contains three special addresses that should no be copied to the state, since it contains references that creates cycles. They can be recreated when the function is resumed.
This commit also removes the clearing of stack from the GDScriptFunctionState destructor, since it should be cleared when the
function exits. The state stack should only be cleared manually if the instance is freed before the state resumes (which is already being done). Otherwise this would destruct the stack twice, causing crashes.
Fixes #57126
Note that I still see leaks after this PR. The(This is now solved in this PR too).SceneTreeTimer
instances created still leak. I'm still not sure why this happens nor whether it's related to this, but I prefer to publish this fix now to avoid the crashing at least. I'll keep investigating the leak, but it's not as urgent.