Skip to content

Reland "[lldb][test] Re-enable bounds safety tests" #9987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ def __run(self, build_dict):
self.expect("expr array_of_bounds_safety_pointers[1]", patterns = [zero_init_pattern])
self.expect("frame variable array_of_bounds_safety_pointers[1]", patterns = [zero_init_pattern])

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

@skipIf(bugnumber="rdar://141363609")
def test_unoptimized(self):
build_dict=dict(CFLAGS_EXTRAS="-Xclang -fbounds-safety")
self.__run(build_dict)
4 changes: 3 additions & 1 deletion lldb/test/API/lang/BoundsSafety/array_of_ptrs/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <ptrcheck.h>
#include <stdlib.h>

int *__bidi_indexable array_of_bounds_safety_pointers[2];

int main() {
array_of_bounds_safety_pointers[0] = (int *)malloc(16); // break here 1
array_of_bounds_safety_pointers[0] = __unsafe_forge_bidi_indexable(
int *, (int *)malloc(16), 16); // break here 1
return 0; // break here 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def partial_oob(self, type_name):
def overflow_oob(self, type_name):
return self.get_idx_var_regex(oob_kind=OOBKind.Overflow, type_name=type_name)

@skipIf(bugnumber="rdar://141363609")
def test_bidi_known_type_size(self):
self.build()

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

@skipIf(bugnumber="rdar://141363609")
def test_bidi_unknown_type_size(self):
self.build()

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

@skipIf(bugnumber="rdar://141363609")
def test_idx_known_type_size(self):
self.build()

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

@skipIf(bugnumber="rdar://141363609")
def test_idx_unknown_type_size(self):
self.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ get_next_fam_struct(FAMS_t *__bidi_indexable current) {
static FAMS_t *__bidi_indexable alloc_fams_buffer(size_t num_fams,
size_t num_elts_in_buffer) {
const size_t buffer_size = sizeof(int) * num_elts_in_buffer;
const size_t alloc_size = num_fams * (sizeof(FAMS_t) + buffer_size);
FAMS_t *__bidi_indexable fams =
malloc(num_fams * (sizeof(FAMS_t) + buffer_size));
__unsafe_forge_bidi_indexable(FAMS_t *, malloc(alloc_size), alloc_size);
// Set the counts and zero init buffer
FAMS_t *__bidi_indexable current = fams;
for (size_t fam_num = 0; fam_num < num_fams; ++fam_num) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ static FAMS_t *__indexable get_next_fam_struct(FAMS_t *__indexable current) {
static FAMS_t *__indexable alloc_fams_buffer(size_t num_fams,
size_t num_elts_in_buffer) {
const size_t buffer_size = sizeof(int) * num_elts_in_buffer;
FAMS_t *__indexable fams = malloc(num_fams * (sizeof(FAMS_t) + buffer_size));
const size_t alloc_size = num_fams * (sizeof(FAMS_t) + buffer_size);
FAMS_t *__indexable fams =
__unsafe_forge_bidi_indexable(FAMS_t *, malloc(alloc_size), alloc_size);
// Set the counts and zero init buffer
FAMS_t *__indexable current = fams;
for (size_t fam_num = 0; fam_num < num_fams; ++fam_num) {
Expand Down