Skip to content

Commit 8afafa9

Browse files
committed
Reland "[lldb][test] Re-enable bounds safety tests"
Reverts #9970 The tests were failing on Linux due to a missing header and missing `__unsafe_forge_` casts. This patch re-enables the tests and fixes the failures on Linux. (cherry picked from commit 1c9e40b1f1420bf19b017c26a1135cb183fc6177)
1 parent d094ad2 commit 8afafa9

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

lldb/test/API/lang/BoundsSafety/array_of_ptrs/TestArrayOfBoundsSafetyPointers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ def __run(self, build_dict):
3737
self.expect("expr array_of_bounds_safety_pointers[1]", patterns = [zero_init_pattern])
3838
self.expect("frame variable array_of_bounds_safety_pointers[1]", patterns = [zero_init_pattern])
3939

40-
@skipIf(bugnumber="rdar://141363609")
4140
def test_optimized(self):
4241
build_dict=dict(CFLAGS_EXTRAS="-O2 -Xclang -fbounds-safety")
4342
self.__run(build_dict)
4443

45-
@skipIf(bugnumber="rdar://141363609")
4644
def test_unoptimized(self):
4745
build_dict=dict(CFLAGS_EXTRAS="-Xclang -fbounds-safety")
4846
self.__run(build_dict)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#include <ptrcheck.h>
12
#include <stdlib.h>
23

34
int *__bidi_indexable array_of_bounds_safety_pointers[2];
45

56
int main() {
6-
array_of_bounds_safety_pointers[0] = (int *)malloc(16); // break here 1
7+
array_of_bounds_safety_pointers[0] = __unsafe_forge_bidi_indexable(
8+
int *, (int *)malloc(16), 16); // break here 1
79
return 0; // break here 2
810
}

lldb/test/API/lang/BoundsSafety/out_of_bounds_pointer/TestOutOfBoundsPointer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def partial_oob(self, type_name):
8080
def overflow_oob(self, type_name):
8181
return self.get_idx_var_regex(oob_kind=OOBKind.Overflow, type_name=type_name)
8282

83-
@skipIf(bugnumber="rdar://141363609")
8483
def test_bidi_known_type_size(self):
8584
self.build()
8685

@@ -151,7 +150,6 @@ def test_bidi_known_type_size(self):
151150
lldbutil.continue_to_breakpoint(self.process, bkpt)
152151
self.expect("frame variable fams2", patterns=[self.bidi_full_oob("FAMS_t *")])
153152

154-
@skipIf(bugnumber="rdar://141363609")
155153
def test_bidi_unknown_type_size(self):
156154
self.build()
157155

@@ -203,7 +201,6 @@ def test_bidi_unknown_type_size(self):
203201
lldbutil.continue_to_breakpoint(self.process, bkpt)
204202
self.expect("frame variable oob_null", patterns=[self.bidi_full_oob("void *")])
205203

206-
@skipIf(bugnumber="rdar://141363609")
207204
def test_idx_known_type_size(self):
208205
self.build()
209206

@@ -255,7 +252,6 @@ def test_idx_known_type_size(self):
255252
lldbutil.continue_to_breakpoint(self.process, bkpt)
256253
self.expect("frame variable fams2", patterns=[self.full_oob("FAMS_t *")])
257254

258-
@skipIf(bugnumber="rdar://141363609")
259255
def test_idx_unknown_type_size(self):
260256
self.build()
261257

lldb/test/API/lang/BoundsSafety/out_of_bounds_pointer/bidi_check_known_type_size.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ get_next_fam_struct(FAMS_t *__bidi_indexable current) {
2626
static FAMS_t *__bidi_indexable alloc_fams_buffer(size_t num_fams,
2727
size_t num_elts_in_buffer) {
2828
const size_t buffer_size = sizeof(int) * num_elts_in_buffer;
29+
const size_t alloc_size = num_fams * (sizeof(FAMS_t) + buffer_size);
2930
FAMS_t *__bidi_indexable fams =
30-
malloc(num_fams * (sizeof(FAMS_t) + buffer_size));
31+
__unsafe_forge_bidi_indexable(FAMS_t *, malloc(alloc_size), alloc_size);
3132
// Set the counts and zero init buffer
3233
FAMS_t *__bidi_indexable current = fams;
3334
for (size_t fam_num = 0; fam_num < num_fams; ++fam_num) {

lldb/test/API/lang/BoundsSafety/out_of_bounds_pointer/idx_check_known_type_size.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ static FAMS_t *__indexable get_next_fam_struct(FAMS_t *__indexable current) {
2424
static FAMS_t *__indexable alloc_fams_buffer(size_t num_fams,
2525
size_t num_elts_in_buffer) {
2626
const size_t buffer_size = sizeof(int) * num_elts_in_buffer;
27-
FAMS_t *__indexable fams = malloc(num_fams * (sizeof(FAMS_t) + buffer_size));
27+
const size_t alloc_size = num_fams * (sizeof(FAMS_t) + buffer_size);
28+
FAMS_t *__indexable fams =
29+
__unsafe_forge_bidi_indexable(FAMS_t *, malloc(alloc_size), alloc_size);
2830
// Set the counts and zero init buffer
2931
FAMS_t *__indexable current = fams;
3032
for (size_t fam_num = 0; fam_num < num_fams; ++fam_num) {

0 commit comments

Comments
 (0)