[all-commits] [llvm/llvm-project] 403e0e: [clang][Interp] Fix crash during `InterpStack` pri...
isuckatcs via All-commits
all-commits at lists.llvm.org
Thu Oct 12 14:26:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 403e0e8cd95f21d5f94f1e0663c2cfe48e54bf08
https://github.com/llvm/llvm-project/commit/403e0e8cd95f21d5f94f1e0663c2cfe48e54bf08
Author: isuckatcs <65320245+isuckatcs at users.noreply.github.com>
Date: 2023-10-12 (Thu, 12 Oct 2023)
Changed paths:
M clang/lib/AST/Interp/InterpStack.cpp
Log Message:
-----------
[clang][Interp] Fix crash during `InterpStack` printing (#68246)
`InterpStack` is using an `std::vector<>` to track the `ItemTypes`. As a
result, the new types are inserted
to the back of the `std::vector<>`, however `dump()` was reading the
types from the front (the bottom
of 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.:
```
Items: 2. Size: 40
0/8: 0
1/40: 0x5590cddc0460 {16, 16, 32}
```
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 to `clang/lib`, where `Interp`
resides. Although the previous
implementation didn't have unittests either, so I'm not sure if we
actually care that much or not.
More information about the All-commits
mailing list