[all-commits] [llvm/llvm-project] adc516: [lldb][InstrumentationRuntime] Make 'data' struct ...
Michael Buch via All-commits
all-commits at lists.llvm.org
Thu Mar 9 16:40:43 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: adc5168d7114190ec7d931a6c346276e19b0e117
https://github.com/llvm/llvm-project/commit/adc5168d7114190ec7d931a6c346276e19b0e117
Author: Michael Buch <michaelbuch12 at gmail.com>
Date: 2023-03-10 (Fri, 10 Mar 2023)
Changed paths:
M lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
M lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
M lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
Log Message:
-----------
[lldb][InstrumentationRuntime] Make 'data' struct anonymous in order to avoid collisions with types in the debuggee
The `UBSAN`/`ASAN` plugins would previously call the internal helper
structure injected into the source expression `struct data { ... };`
This occasionally collided with user-defined types of the same (quite
common) name. In the presence of varibale with the same name LLDB would
simply fail to run the injected `InstrumentationRuntime` expressions
with:
```
warning: cannot evaluate AddressSanitizer expression:
expression failed to parse:
error: <user expression 2>:2:5: must use 'struct' tag to refer to type 'data' in this scope
data t;
```
In the presence of another type called 'data', LLDB would most likely
crash with something like:
```
0x00000001198de614 clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) + 1088
0x00000001198de614 clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) + 1088
0x0000000119907930 clang::ASTImporter::ImportDefinition(clang::Decl*) + 596
0x00000001163db928 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(clang::Decl*, clang::Decl*) + 100
0x00000001163da070 (anonymous namespace)::CompleteTagDeclsScope::~CompleteTagDeclsScope() + 572
...
```
...because it got the types confused.
This patch makes these structures anonymous so there's no
chance of clashing with other types in the program. This is
already the approach taken in `UBSan/InstrumentationRuntimeABSan.cpp`.
**Testing**
- API tests still pass
- Tested manually that the `memory history` command now works in the presence of a local called `data`
Differential Revision: https://reviews.llvm.org/D145569
More information about the All-commits
mailing list