Skip to content

Commit f1fd9d7

Browse files
authored
[compiler-rt][ASan] Remove alignment message in ASan error reporting (#94103)
This commit removes unnecessary alignment check and message in ASan error reporting functions (like `ErrorBadParamsToAnnotateContiguousContainer::Print()`), as alignment is no longer required starting from LLVM 16. Without that commit, this message can be observed only when arguments are truly incorrect and `beg` is unaligned. Just unaligned `beg` does not result in any message being printed. Related commits: - dd1b7b7 - 1c5ad6d
1 parent 8866fa1 commit f1fd9d7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

compiler-rt/lib/asan/asan_errors.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ void ErrorBadParamsToAnnotateContiguousContainer::Print() {
328328
" new_mid : %p\n",
329329
(void *)beg, (void *)end, (void *)old_mid, (void *)new_mid);
330330
uptr granularity = ASAN_SHADOW_GRANULARITY;
331-
if (!IsAligned(beg, granularity))
332-
Report("ERROR: beg is not aligned by %zu\n", granularity);
333331
stack->Print();
334332
ReportErrorSummary(scariness.GetDescription(), stack);
335333
}
@@ -348,8 +346,6 @@ void ErrorBadParamsToAnnotateDoubleEndedContiguousContainer::Print() {
348346
(void *)old_container_end, (void *)new_container_beg,
349347
(void *)new_container_end);
350348
uptr granularity = ASAN_SHADOW_GRANULARITY;
351-
if (!IsAligned(storage_beg, granularity))
352-
Report("ERROR: storage_beg is not aligned by %zu\n", granularity);
353349
stack->Print();
354350
ReportErrorSummary(scariness.GetDescription(), stack);
355351
}

compiler-rt/test/asan/TestCases/contiguous_container_crash.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clangxx_asan -O %s -o %t
22
// RUN: not %run %t crash 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
33
// RUN: not %run %t bad-bounds 2>&1 | FileCheck --check-prefix=CHECK-BAD-BOUNDS %s
4+
// RUN: not %run %t unaligned-bad-bounds 2>&1 | FileCheck --check-prefix=CHECK-UNALIGNED-BAD-BOUNDS %s --implicit-check-not="beg is not aligned by"
45
// RUN: not %run %t odd-alignment 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
56
// RUN: not %run %t odd-alignment-end 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
67
// RUN: %env_asan_opts=detect_container_overflow=0 %run %t crash
@@ -35,6 +36,13 @@ void BadBounds() {
3536
&t[0] + 50);
3637
}
3738

39+
void UnalignedBadBounds() {
40+
char t[100];
41+
// CHECK-UNALIGNED-BAD-BOUNDS: ERROR: AddressSanitizer: bad parameters to __sanitizer_annotate_contiguous_container
42+
__sanitizer_annotate_contiguous_container(&t[1], &t[0] + 100, &t[0] + 101,
43+
&t[0] + 50);
44+
}
45+
3846
int OddAlignment() {
3947
int t[100];
4048
t[60] = 0;
@@ -57,6 +65,8 @@ int main(int argc, char **argv) {
5765
return TestCrash();
5866
else if (!strcmp(argv[1], "bad-bounds"))
5967
BadBounds();
68+
else if (!strcmp(argv[1], "unaligned-bad-bounds"))
69+
UnalignedBadBounds();
6070
else if (!strcmp(argv[1], "odd-alignment"))
6171
return OddAlignment();
6272
else if (!strcmp(argv[1], "odd-alignment-end"))

0 commit comments

Comments
 (0)