Commit 4012c1f
authored
[lldb][test] Avoid out-of-bounds reads in TestConflictingSymbol.py (#172792)
Generic data variables are considered to be of the type `void *&`, see
`ClangExpressionDeclMap::AddOneGenericVariable()`. On 64-bit platforms
(e.g. AArch64), this type is 8 bytes long, while the
`conflicting_symbol` variables are defined as `int`, which is typically
4 bytes. `test_conflicting_symbols` could fail if the next 4 bytes in the
memory after any of the variables are not zero. This can be reproduced
by adding a variable with a non-zero value after `conflicting_symbol`:
```
--- a/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
+++ b/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
@@ -1 +1,2 @@
int __attribute__ ((visibility("hidden"))) conflicting_symbol = 11111;
+int guard = 1;
```
In this case, the test fails with:
```
AssertionError: Ran command:
"expr (unsigned long long)conflicting_symbol"
Got output:
(unsigned long long) $0 = 4294978407
Expecting sub string: "11111" (was not found)
Symbol from One should be found
```
Note that 4294978407 = 0x100002B67 = 1 * 2^32 + 11111.1 parent b184f00 commit 4012c1f
File tree
3 files changed
+9
-7
lines changed- lldb/test/API/lang/c/conflicting-symbol
- One
- Two
3 files changed
+9
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
89 | | - | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments