Skip to content

Commit ce1b2c8

Browse files
committed
[lldb][test] Fix flaky DIL array subscript test by recuding array indexes
This test has been flaky on Linaro's Windows on Arm bot and I was able to reproduce it within 10 or so runs locally. When it fails it's because we failed to read the value of int_arr[100]. When that happens the memory looks like this: ``` [0x0000006bf88fd000-0x0000006bf8900000) rw- <-- sp (0x0000006bf88ffe20) [0x0000006bf8900000-0x0000025fec900000) --- <-- int_arr[100] (0x0000006bf8900070) ``` The first region is the stack and the stack pointer is pointing within that region, as expected. The second region is where we are trying to read int_arr[100] from and this is not mapped because we're trying to read above the start of the stack. Sometimes the test passes I think because ASLR / DYNAMICBASE moves the start of the stack down enough so there is some readable memory at the top. https://learn.microsoft.com/en-us/cpp/build/reference/dynamicbase?view=msvc-170 Note "Because ASLR can't be disabled on ARM, ARM64, or ARM64EC architectures, /DYNAMICBASE:NO isn't supported for these targets.". Which means on this bot, the layout is definitely being randomised. We don't need to be testing indexes this large. So I've changed the two test indexes to 3 (1 beyond the end) and 10 (a larger distance beyond the end). We know that index 42 always worked on the bot, so 10 should be fine, and did not fail locally.
1 parent 11e804f commit ce1b2c8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, value=None, type=None
1919
self.runCmd("settings set target.experimental.use-DIL true")
2020
self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
2121

22-
# int_arr[100] sometimes points to above the stack region, fix coming soon.
23-
@skipIfWindows
2422
def test_subscript(self):
2523
self.build()
2624
lldbutil.run_to_source_breakpoint(
@@ -53,9 +51,10 @@ def test_subscript(self):
5351
# Both typedefs and refs
5452
self.expect("frame var 'td_int_arr_ref[td_int_idx_1_ref]'", error=True)
5553

56-
# Test for index out of bounds.
57-
self.expect_var_path("int_arr[42]", True, type="int")
58-
self.expect_var_path("int_arr[100]", True, type="int")
54+
# Test for index out of bounds. 1 beyond the end.
55+
self.expect_var_path("int_arr[3]", True, type="int")
56+
# Far beyond the end (but not far enough to be off the top of the stack).
57+
self.expect_var_path("int_arr[10]", True, type="int")
5958

6059
# Test address-of of the subscripted value.
6160
self.expect_var_path("*(&int_arr[1])", value="2")

0 commit comments

Comments
 (0)