[clang][Interp] Fix crash during InterpStack
printing
#68246
Merged
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.
InterpStack
is using anstd::vector<>
to track theItemTypes
. As a result, the new types are insertedto the back of the
std::vector<>
, howeverdump()
was reading the types from the front (the bottomof the stack) and printing the value on the top of the stack.
This lead to a crash if the type on the bottom had a different type from the type on the top. E.g.:
The same method also miscalculated the offsets during printing the stack, which was a source of
incorrect stack dumps and future crashes.
This patch changes the order of iteration of the types and fixes the offset calculation.
As for testing the change, the issue is that it needs to be done as a unittest, however from
clang/unittests
we don't have access toclang/lib
, whereInterp
resides. Although the previousimplementation didn't have unittests either, so I'm not sure if we actually care that much or not.