fix!(codegen): initialize function outputs and omitted arguments (1.0.x) - #1959
Open
Angus-Bethke-Bachmann wants to merge 1 commit into
Open
Angus-Bethke-Bachmann wants to merge 1 commit into
Angus-Bethke-Bachmann wants to merge 1 commit into
Conversation
Problem: When a call left out an argument, the compiler passed the contents of a stack slot that nothing had written, so the callee saw whatever the previous call had left there. A VAR_OUTPUT of a function or method also started every call with the caller's current value, so a path that did not assign the output leaked that value back. Solution: An argument that is left out, or written empty, carries the declared default or zero. Outputs of functions and methods are initialized like local variables at the start of each call: codegen zero-fills them through the caller's address and the init lowering adds the constructor call and initializer assignment. Variable length array outputs keep the caller's bounds. Non-constant output initializers such as ADR(THIS^) are left to the lowered initializer. Cherry-picked from the master PR for PRG-4940. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Build Artifacts🐧 Linux
From workflow run 🪟 Windows
From workflow run |
Collaborator
|
is this really breaking? (fix!) |
Contributor
Author
I wasn't 100% sure so I asked claude to flag it, different results are returned on a recompile of the same code. I think this is technically breaking but the returned results were wrong before... so I dunno. I don't mind removing it (the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem: When a call left out an argument, the compiler passed the contents of a stack slot that nothing had written, so the callee saw whatever the previous call had left there. A VAR_OUTPUT of a function or method also started every call with the caller's current value, so a path that did not assign the output leaked that value back.
Solution: An argument that is left out, or written empty, carries the declared default or zero. Outputs of functions and methods are initialized like local variables at the start of each call: codegen zero-fills them through the caller's address and the init lowering adds the constructor call and initializer assignment. Variable length array outputs keep the caller's bounds. Non-constant output initializers such as ADR(THIS^) are left to the lowered initializer.
Cherry-picked from the master PR for PRG-4940.