Repository navigation
Give a cppia call to a host function its type before it links - #510
Open
dimensionscape wants to merge 2 commits into
Open
dimensionscape wants to merge 2 commits into
dimensionscape wants to merge 2 commits into
Conversation
CallHaxe set returnType in link, after checking the argument count, so a call with the wrong count, which records the miss and returns early, kept an uninitialized type. An expression that asks while it links, as an addition, a comparison, a negation or a switch does, read it: undefined, and UBSan reported it in the fuzz job of #500 as a load of 80 into ExprType. The constructor sets the type from the host's signature now. CppiaHostMismatch adds to the result of such a call.
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.
CallHaxesetreturnTypeinlink, after it checked the argument count. A call with the wrong count records the miss and returns early, so its type stayed uninitialized, and an expression that asks the type while it links read it: an addition, a comparison, a negation or a switch. The fuzz job on #500 caught it:#500 added that read in
Call::link; on main,OpAdd,OpCompareBase,OpNeg,BinOpandSwitchExprread it the same way. The constructor now sets the type from the host's signature, so it is known before link and on the early return.CppiaHostMismatchgets a script that adds 1 to the result of such a call. It fails to load naming the call, interpreted and under the JIT. UBSan only reports the read when the leftover value is out of range, so the test cannot catch the old code every time; a probe in main'sgetTypeshowed the new script reaching the read.Checked with GCC 13 and UBSan on Linux: CppiaHostMismatch matches
stdout.txtwith the change.