Skip to content

Conversation

@honeygoyal
Copy link

No description provided.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Honey Goyal (honeygoyal)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/169775.diff

6 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_errors.cpp (+55)
  • (modified) compiler-rt/lib/asan/asan_errors.h (+66)
  • (modified) compiler-rt/lib/asan/asan_interceptors.cpp (+97-18)
  • (modified) compiler-rt/lib/asan/asan_report.cpp (+30)
  • (modified) compiler-rt/lib/asan/asan_report.h (+5)
  • (added) compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp (+17)
diff --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp
index 99d6bdac3d720..2a949a14b2967 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -266,6 +266,61 @@ void ErrorAllocationSizeTooBig::Print() {
   ReportErrorSummary(scariness.GetDescription(), stack);
 }
 
+void ErrorMmapAddrOverflow::Print() {
+  Decorator d;
+  Printf("%s", d.Error());
+  Report("ERROR: AddressSanitizer: mmap requested memory range (0x%zx + 0x%zx) "
+         "causes address overflow\n", start, length);
+  Printf("%s", d.Default());
+  stack->Print();
+  PrintHintAllocatorCannotReturnNull();
+  ReportErrorSummary(scariness.GetDescription(), stack);
+}
+
+void ErrorMmapShadowOverlap::Print() {
+  Decorator d;
+  Printf("%s", d.Error());
+  Report("ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx "
+         "overlaps with ASan shadow memory\n", start, end);
+  Printf("%s", d.Default());
+  stack->Print();
+  PrintHintAllocatorCannotReturnNull();
+  ReportErrorSummary(scariness.GetDescription(), stack); 
+}
+
+void ErrorMmapOutsideRange::Print() {
+  Decorator d;
+  Printf("%s", d.Error());
+  Report("ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx is "
+         "outside ASan's instrumentable application memory range\n", start, end);
+  Printf("%s", d.Default());
+  stack->Print();
+  PrintHintAllocatorCannotReturnNull();
+  ReportErrorSummary(scariness.GetDescription(), stack);
+}
+
+void ErrorMunmapShadowOverlap::Print() {
+  Decorator d;
+  Printf("%s", d.Error());
+  Report("ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx "
+         "overlaps with ASan shadow memory\n", start, end);
+  Printf("%s", d.Default());
+  stack->Print();
+  PrintHintAllocatorCannotReturnNull();
+  ReportErrorSummary(scariness.GetDescription(), stack);
+}
+
+void ErrorMunmapOutsideRange::Print() {
+  Decorator d;
+  Printf("%s", d.Error());
+  Report("ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx is "
+         "outside ASan's instrumentable application memory range\n", start, end);
+  Printf("%s", d.Default());
+  stack->Print();
+  PrintHintAllocatorCannotReturnNull();
+  ReportErrorSummary(scariness.GetDescription(), stack);
+}
+
 void ErrorRssLimitExceeded::Print() {
   Decorator d;
   Printf("%s", d.Error());
diff --git a/compiler-rt/lib/asan/asan_errors.h b/compiler-rt/lib/asan/asan_errors.h
index f339b35d2a764..13e66865a6eb9 100644
--- a/compiler-rt/lib/asan/asan_errors.h
+++ b/compiler-rt/lib/asan/asan_errors.h
@@ -249,6 +249,67 @@ struct ErrorAllocationSizeTooBig : ErrorBase {
   void Print();
 };
 
+struct ErrorMmapAddrOverflow : ErrorBase {
+  const BufferedStackTrace *stack;
+  uptr start;
+  uptr length;
+  ErrorMmapAddrOverflow() = default;
+  ErrorMmapAddrOverflow(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr len)
+      : ErrorBase(tid, 10, "bad-mmap-overflow"), 
+        stack(stack_), 
+        start(start_), 
+        length(len) {}
+  void Print();
+};
+
+struct ErrorMmapShadowOverlap : ErrorBase {
+  const BufferedStackTrace *stack;
+  uptr start, end;
+  ErrorMmapShadowOverlap() = default;
+  ErrorMmapShadowOverlap(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
+      : ErrorBase(tid, 10, "bad-mmap-overlap"), 
+        stack(stack_), 
+        start(start_), 
+        end(end_) {}
+  void Print();
+};
+
+struct ErrorMmapOutsideRange : ErrorBase {
+  const BufferedStackTrace *stack;
+  uptr start, end;
+  ErrorMmapOutsideRange() = default;
+  ErrorMmapOutsideRange(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
+      : ErrorBase(tid, 10, "bad-mmap-out-of-range"), 
+        stack(stack_), 
+        start(start_), 
+        end(end_) {}
+  void Print();
+};
+
+struct ErrorMunmapShadowOverlap : ErrorBase {
+  const BufferedStackTrace *stack;
+  uptr start, end;
+  ErrorMunmapShadowOverlap() = default;
+  ErrorMunmapShadowOverlap(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
+      : ErrorBase(tid, 10, "bad-munmap-overlap"), 
+        stack(stack_), 
+        start(start_), 
+        end(end_) {}
+  void Print();
+};
+
+struct ErrorMunmapOutsideRange : ErrorBase {
+  const BufferedStackTrace *stack;
+  uptr start, end;
+  ErrorMunmapOutsideRange() = default;
+  ErrorMunmapOutsideRange(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
+      : ErrorBase(tid, 10, "bad-munmap-out-of-range"), 
+        stack(stack_), 
+        start(start_), 
+        end(end_) {}
+  void Print();
+};
+
 struct ErrorRssLimitExceeded : ErrorBase {
   const BufferedStackTrace *stack;
 
@@ -433,6 +494,11 @@ struct ErrorGeneric : ErrorBase {
   macro(InvalidAlignedAllocAlignment)                      \
   macro(InvalidPosixMemalignAlignment)                     \
   macro(AllocationSizeTooBig)                              \
+  macro(MmapAddrOverflow)                                  \
+  macro(MmapShadowOverlap)                                 \
+  macro(MmapOutsideRange)                                  \
+  macro(MunmapShadowOverlap)                               \
+  macro(MunmapOutsideRange)                                \
   macro(RssLimitExceeded)                                  \
   macro(OutOfMemory)                                       \
   macro(StringFunctionMemoryRangesOverlap)                 \
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 8643271e89d70..5cd586305157e 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "asan_interceptors.h"
-
+#include "sanitizer_common/sanitizer_common.h"
 #include "asan_allocator.h"
 #include "asan_internal.h"
 #include "asan_mapping.h"
@@ -47,6 +47,12 @@
 #    define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
 #  endif
 
+#if !defined(MAP_FAILED)
+#  define MAP_FAILED ((void *)-1)
+#endif
+
+#define MAP_FIXED        0x0010 /* [MF|SHM] interpret addr exactly */
+
 namespace __asan {
 
 #define ASAN_READ_STRING_OF_LEN(ctx, s, len, n)                 \
@@ -87,6 +93,26 @@ int OnExit() {
   return 0;
 }
 
+static inline bool RangeOverlaps(uptr beg, uptr end_excl, uptr seg_beg, uptr seg_end_incl) {
+  if (!seg_beg && !seg_end_incl) return false;
+  uptr seg_end_excl = seg_end_incl + 1;
+  return beg < seg_end_excl && end_excl > seg_beg;
+}
+
+static inline bool IntersectsShadowOrGap(uptr beg, uptr end_excl) {
+  // Check shadow regions
+  if (RangeOverlaps(beg, end_excl, kLowShadowBeg, kLowShadowEnd)) return true;
+  if (kMidShadowBeg && RangeOverlaps(beg, end_excl, kMidShadowBeg, kMidShadowEnd)) return true;
+  if (RangeOverlaps(beg, end_excl, kHighShadowBeg, kHighShadowEnd)) return true;
+
+  // Check shadow gaps
+  if (RangeOverlaps(beg, end_excl, kShadowGapBeg, kShadowGapEnd)) return true;
+  if (kShadowGap2Beg && RangeOverlaps(beg, end_excl, kShadowGap2Beg, kShadowGap2End)) return true;
+  if (kShadowGap3Beg && RangeOverlaps(beg, end_excl, kShadowGap3Beg, kShadowGap3End)) return true;
+
+  return false;
+}
+
 } // namespace __asan
 
 // ---------------------- Wrappers ---------------- {{{1
@@ -157,45 +183,98 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
     }
 
 template <class Mmap>
-static void* mmap_interceptor(Mmap real_mmap, void *addr, SIZE_T length,
+static void *mmap_interceptor(Mmap real_mmap, void *addr, SIZE_T length,
                               int prot, int flags, int fd, OFF64_T offset) {
+  if (length == 0)
+    return real_mmap(addr, length, prot, flags, fd, offset);
+
+  uptr start = reinterpret_cast<uptr>(addr);
+  uptr end_excl;
+  if (UNLIKELY(__builtin_add_overflow(start, (uptr)length, &end_excl))) {
+    GET_STACK_TRACE_FATAL_HERE;
+    ReportMmapAddrOverflow(start, length, &stack);
+    return MAP_FAILED;
+  }
+
+  if (flags & MAP_FIXED) {
+    if (__asan::IntersectsShadowOrGap(start, end_excl)) {
+      errno = errno_EINVAL;
+      GET_STACK_TRACE_FATAL_HERE;
+      ReportMmapShadowOverlap(start, end_excl, &stack);      
+      if (common_flags()->abort_on_error) {
+        Abort();
+      }
+      return MAP_FAILED;
+    }
+    if (!AddrIsInMem(start) || !AddrIsInMem(end_excl - 1)) {
+      errno = errno_ENOMEM;
+      GET_STACK_TRACE_FATAL_HERE;
+      ReportMmapOutsideRange(start, end_excl, &stack);
+      return MAP_FAILED;
+    }
+  } else {
+    if (addr && __asan::IntersectsShadowOrGap(start, start + 1))
+      addr = nullptr;
+  }
+
   void *res = real_mmap(addr, length, prot, flags, fd, offset);
-  if (length && res != (void *)-1) {
+  if (res != MAP_FAILED) {
     const uptr beg = reinterpret_cast<uptr>(res);
-    DCHECK(IsAligned(beg, GetPageSize()));
-    SIZE_T rounded_length = RoundUpTo(length, GetPageSize());
-    // Only unpoison shadow if it's an ASAN managed address.
-    if (AddrIsInMem(beg) && AddrIsInMem(beg + rounded_length - 1))
-      PoisonShadow(beg, RoundUpTo(length, GetPageSize()), 0);
+    const uptr page = GetPageSize();
+    const uptr sz = RoundUpTo(length, page);
+    if (AddrIsInMem(beg) && AddrIsInMem(beg + sz - 1)) {
+      PoisonShadow(beg, sz, 0);
+    }
   }
   return res;
 }
 
 template <class Munmap>
 static int munmap_interceptor(Munmap real_munmap, void *addr, SIZE_T length) {
-  // We should not tag if munmap fail, but it's to late to tag after
-  // real_munmap, as the pages could be mmaped by another thread.
+  if (length == 0)
+    return real_munmap(addr, length);
+
   const uptr beg = reinterpret_cast<uptr>(addr);
-  if (length && IsAligned(beg, GetPageSize())) {
-    SIZE_T rounded_length = RoundUpTo(length, GetPageSize());
-    // Protect from unmapping the shadow.
-    if (AddrIsInMem(beg) && AddrIsInMem(beg + rounded_length - 1))
-      PoisonShadow(beg, rounded_length, 0);
+  uptr end_excl;
+  if (UNLIKELY(__builtin_add_overflow(beg, (uptr)length, &end_excl))) {
+    errno = errno_EINVAL;
+    GET_STACK_TRACE_FATAL_HERE;
+    ReportMunmapShadowOverlap(beg, end_excl, &stack);
+    return -1;
   }
-  return real_munmap(addr, length);
+
+  if ((AddrIsInMem(beg) || AddrIsInMem(end_excl - 1)) &&
+      (!AddrIsInMem(beg) || !AddrIsInMem(end_excl - 1))) {
+    errno = errno_EINVAL;
+    GET_STACK_TRACE_FATAL_HERE;
+    ReportMunmapOutsideRange(beg, end_excl, &stack);
+    return -1;
+  }
+
+  int res = real_munmap(addr, length);
+
+  if (res == 0) {
+    const uptr page = GetPageSize();
+    const uptr aligned_beg = RoundDownTo(beg, page);
+    const uptr aligned_end = RoundUpTo(end_excl, page);
+    if (AddrIsInMem(aligned_beg) && AddrIsInMem(aligned_end - 1)) {
+      PoisonShadow(aligned_beg, aligned_end - aligned_beg, 0);
+    }
+  }
+  return res;
 }
 
 #  define COMMON_INTERCEPTOR_MMAP_IMPL(ctx, mmap, addr, length, prot, flags,   \
                                      fd, offset)                               \
   do {                                                                         \
     (void)(ctx);                                                               \
-    return mmap_interceptor(REAL(mmap), addr, sz, prot, flags, fd, off);       \
+    return mmap_interceptor(REAL(mmap), addr, length, prot, flags, fd, offset);\
   } while (false)
 
 #  define COMMON_INTERCEPTOR_MUNMAP_IMPL(ctx, addr, length)                    \
   do {                                                                         \
     (void)(ctx);                                                               \
-    return munmap_interceptor(REAL(munmap), addr, sz);                         \
+    return munmap_interceptor(REAL(munmap), addr, length);                     \
   } while (false)
 
 #if CAN_SANITIZE_LEAKS
diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index e049a21e4e16d..fbefc63b4dace 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -343,6 +343,36 @@ void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,
   in_report.ReportError(error);
 }
 
+void ReportMmapAddrOverflow(uptr start, uptr length, BufferedStackTrace *stack) {
+  ScopedInErrorReport in_report(/*fatal*/ true);
+  ErrorMmapAddrOverflow error(GetCurrentTidOrInvalid(), stack, start, length);
+  in_report.ReportError(error);
+}
+
+void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack) {
+  ScopedInErrorReport in_report(/*fatal*/ true);
+  ErrorMmapShadowOverlap error(GetCurrentTidOrInvalid(), stack, start, end);
+  in_report.ReportError(error);
+}
+
+void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack) {
+  ScopedInErrorReport in_report(/*fatal*/ true);
+  ErrorMmapOutsideRange error(GetCurrentTidOrInvalid(), stack, start, end);
+  in_report.ReportError(error);
+}
+
+void ReportMunmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack) {
+  ScopedInErrorReport in_report(/*fatal*/ true);
+  ErrorMunmapShadowOverlap error(GetCurrentTidOrInvalid(), stack, start, end);
+  in_report.ReportError(error);
+}
+
+void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack) {
+  ScopedInErrorReport in_report(/*fatal*/ true);
+  ErrorMunmapOutsideRange error(GetCurrentTidOrInvalid(), stack, start, end);
+  in_report.ReportError(error);
+}
+
 void ReportRssLimitExceeded(BufferedStackTrace *stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorRssLimitExceeded error(GetCurrentTidOrInvalid(), stack);
diff --git a/compiler-rt/lib/asan/asan_report.h b/compiler-rt/lib/asan/asan_report.h
index 3143d83abe390..e7f653cf6c3f6 100644
--- a/compiler-rt/lib/asan/asan_report.h
+++ b/compiler-rt/lib/asan/asan_report.h
@@ -73,6 +73,11 @@ void ReportInvalidPosixMemalignAlignment(uptr alignment,
                                          BufferedStackTrace *stack);
 void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,
                                 BufferedStackTrace *stack);
+void ReportMmapAddrOverflow(uptr start, uptr length, BufferedStackTrace *stack);
+void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack);
+void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack);
+void ReportMunmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack);
+void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack);                                
 void ReportRssLimitExceeded(BufferedStackTrace *stack);
 void ReportOutOfMemory(uptr requested_size, BufferedStackTrace *stack);
 void ReportStringFunctionMemoryRangesOverlap(const char *function,
diff --git a/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp b/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
new file mode 100644
index 0000000000000..5833159f09ab2
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
@@ -0,0 +1,17 @@
+// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <sys/mman.h>
+
+#define ASAN_AIX_SHADOW_OFFSET 0x0a01000000000000ULL
+
+int main() {
+    size_t map_size = 4096;
+    void* addr = (void*)ASAN_AIX_SHADOW_OFFSET;
+    void* ptr = mmap(addr, map_size, PROT_READ | PROT_WRITE,
+                     MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+    if (ptr != MAP_FAILED) munmap(ptr, map_size);
+    return 0;
+}
+
+// CHECK: ERROR: AddressSanitizer: mmap requested memory range
+// CHECK: overlaps with ASan shadow memory

@@ -0,0 +1,17 @@
// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test needs something like // REQUIRES: system-aix, otherwise it will fail on non-AIX systems.

# endif

#if !defined(MAP_FAILED)
# define MAP_FAILED ((void *)-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_fixed (in lowercase) is defined in compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp for this purpose (example usage: compiler-rt/lib/hwasan/hwasan_interceptors.cpp).

ReportErrorSummary(scariness.GetDescription(), stack);
}

void ErrorMunmapShadowOverlap::Print() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the error-reporting necessary? If ASan can't honor a fixed memory mapping for whatever reason, it suffices to return MAP_FAILED (this is what HWASan's interceptor does); the shadow is an implementation detail that the user doesn't need to know about.

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp compiler-rt/lib/asan/asan_errors.cpp compiler-rt/lib/asan/asan_errors.h compiler-rt/lib/asan/asan_interceptors.cpp compiler-rt/lib/asan/asan_report.cpp compiler-rt/lib/asan/asan_report.h --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp
index 2a949a14b..0cc747855 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -269,8 +269,10 @@ void ErrorAllocationSizeTooBig::Print() {
 void ErrorMmapAddrOverflow::Print() {
   Decorator d;
   Printf("%s", d.Error());
-  Report("ERROR: AddressSanitizer: mmap requested memory range (0x%zx + 0x%zx) "
-         "causes address overflow\n", start, length);
+  Report(
+      "ERROR: AddressSanitizer: mmap requested memory range (0x%zx + 0x%zx) "
+      "causes address overflow\n",
+      start, length);
   Printf("%s", d.Default());
   stack->Print();
   PrintHintAllocatorCannotReturnNull();
@@ -280,19 +282,23 @@ void ErrorMmapAddrOverflow::Print() {
 void ErrorMmapShadowOverlap::Print() {
   Decorator d;
   Printf("%s", d.Error());
-  Report("ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx "
-         "overlaps with ASan shadow memory\n", start, end);
+  Report(
+      "ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx "
+      "overlaps with ASan shadow memory\n",
+      start, end);
   Printf("%s", d.Default());
   stack->Print();
   PrintHintAllocatorCannotReturnNull();
-  ReportErrorSummary(scariness.GetDescription(), stack); 
+  ReportErrorSummary(scariness.GetDescription(), stack);
 }
 
 void ErrorMmapOutsideRange::Print() {
   Decorator d;
   Printf("%s", d.Error());
-  Report("ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx is "
-         "outside ASan's instrumentable application memory range\n", start, end);
+  Report(
+      "ERROR: AddressSanitizer: mmap requested memory range 0x%zx-0x%zx is "
+      "outside ASan's instrumentable application memory range\n",
+      start, end);
   Printf("%s", d.Default());
   stack->Print();
   PrintHintAllocatorCannotReturnNull();
@@ -302,8 +308,10 @@ void ErrorMmapOutsideRange::Print() {
 void ErrorMunmapShadowOverlap::Print() {
   Decorator d;
   Printf("%s", d.Error());
-  Report("ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx "
-         "overlaps with ASan shadow memory\n", start, end);
+  Report(
+      "ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx "
+      "overlaps with ASan shadow memory\n",
+      start, end);
   Printf("%s", d.Default());
   stack->Print();
   PrintHintAllocatorCannotReturnNull();
@@ -313,8 +321,10 @@ void ErrorMunmapShadowOverlap::Print() {
 void ErrorMunmapOutsideRange::Print() {
   Decorator d;
   Printf("%s", d.Error());
-  Report("ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx is "
-         "outside ASan's instrumentable application memory range\n", start, end);
+  Report(
+      "ERROR: AddressSanitizer: munmap requested memory range 0x%zx-0x%zx is "
+      "outside ASan's instrumentable application memory range\n",
+      start, end);
   Printf("%s", d.Default());
   stack->Print();
   PrintHintAllocatorCannotReturnNull();
diff --git a/compiler-rt/lib/asan/asan_errors.h b/compiler-rt/lib/asan/asan_errors.h
index 13e66865a..035f2872d 100644
--- a/compiler-rt/lib/asan/asan_errors.h
+++ b/compiler-rt/lib/asan/asan_errors.h
@@ -250,62 +250,67 @@ struct ErrorAllocationSizeTooBig : ErrorBase {
 };
 
 struct ErrorMmapAddrOverflow : ErrorBase {
-  const BufferedStackTrace *stack;
+  const BufferedStackTrace* stack;
   uptr start;
   uptr length;
   ErrorMmapAddrOverflow() = default;
-  ErrorMmapAddrOverflow(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr len)
-      : ErrorBase(tid, 10, "bad-mmap-overflow"), 
-        stack(stack_), 
-        start(start_), 
+  ErrorMmapAddrOverflow(u32 tid, BufferedStackTrace* stack_, uptr start_,
+                        uptr len)
+      : ErrorBase(tid, 10, "bad-mmap-overflow"),
+        stack(stack_),
+        start(start_),
         length(len) {}
   void Print();
 };
 
 struct ErrorMmapShadowOverlap : ErrorBase {
-  const BufferedStackTrace *stack;
+  const BufferedStackTrace* stack;
   uptr start, end;
   ErrorMmapShadowOverlap() = default;
-  ErrorMmapShadowOverlap(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
-      : ErrorBase(tid, 10, "bad-mmap-overlap"), 
-        stack(stack_), 
-        start(start_), 
+  ErrorMmapShadowOverlap(u32 tid, BufferedStackTrace* stack_, uptr start_,
+                         uptr end_)
+      : ErrorBase(tid, 10, "bad-mmap-overlap"),
+        stack(stack_),
+        start(start_),
         end(end_) {}
   void Print();
 };
 
 struct ErrorMmapOutsideRange : ErrorBase {
-  const BufferedStackTrace *stack;
+  const BufferedStackTrace* stack;
   uptr start, end;
   ErrorMmapOutsideRange() = default;
-  ErrorMmapOutsideRange(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
-      : ErrorBase(tid, 10, "bad-mmap-out-of-range"), 
-        stack(stack_), 
-        start(start_), 
+  ErrorMmapOutsideRange(u32 tid, BufferedStackTrace* stack_, uptr start_,
+                        uptr end_)
+      : ErrorBase(tid, 10, "bad-mmap-out-of-range"),
+        stack(stack_),
+        start(start_),
         end(end_) {}
   void Print();
 };
 
 struct ErrorMunmapShadowOverlap : ErrorBase {
-  const BufferedStackTrace *stack;
+  const BufferedStackTrace* stack;
   uptr start, end;
   ErrorMunmapShadowOverlap() = default;
-  ErrorMunmapShadowOverlap(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
-      : ErrorBase(tid, 10, "bad-munmap-overlap"), 
-        stack(stack_), 
-        start(start_), 
+  ErrorMunmapShadowOverlap(u32 tid, BufferedStackTrace* stack_, uptr start_,
+                           uptr end_)
+      : ErrorBase(tid, 10, "bad-munmap-overlap"),
+        stack(stack_),
+        start(start_),
         end(end_) {}
   void Print();
 };
 
 struct ErrorMunmapOutsideRange : ErrorBase {
-  const BufferedStackTrace *stack;
+  const BufferedStackTrace* stack;
   uptr start, end;
   ErrorMunmapOutsideRange() = default;
-  ErrorMunmapOutsideRange(u32 tid, BufferedStackTrace *stack_, uptr start_, uptr end_)
-      : ErrorBase(tid, 10, "bad-munmap-out-of-range"), 
-        stack(stack_), 
-        start(start_), 
+  ErrorMunmapOutsideRange(u32 tid, BufferedStackTrace* stack_, uptr start_,
+                          uptr end_)
+      : ErrorBase(tid, 10, "bad-munmap-out-of-range"),
+        stack(stack_),
+        start(start_),
         end(end_) {}
   void Print();
 };
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 5cd586305..f127a0e8e 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "asan_interceptors.h"
-#include "sanitizer_common/sanitizer_common.h"
+
 #include "asan_allocator.h"
 #include "asan_internal.h"
 #include "asan_mapping.h"
@@ -23,6 +23,7 @@
 #include "asan_suppressions.h"
 #include "asan_thread.h"
 #include "lsan/lsan_common.h"
+#include "sanitizer_common/sanitizer_common.h"
 #include "sanitizer_common/sanitizer_errno.h"
 #include "sanitizer_common/sanitizer_internal_defs.h"
 #include "sanitizer_common/sanitizer_libc.h"
@@ -47,11 +48,11 @@
 #    define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
 #  endif
 
-#if !defined(MAP_FAILED)
-#  define MAP_FAILED ((void *)-1)
-#endif
+#  if !defined(MAP_FAILED)
+#    define MAP_FAILED ((void*)-1)
+#  endif
 
-#define MAP_FIXED        0x0010 /* [MF|SHM] interpret addr exactly */
+#  define MAP_FIXED 0x0010 /* [MF|SHM] interpret addr exactly */
 
 namespace __asan {
 
@@ -93,22 +94,33 @@ int OnExit() {
   return 0;
 }
 
-static inline bool RangeOverlaps(uptr beg, uptr end_excl, uptr seg_beg, uptr seg_end_incl) {
-  if (!seg_beg && !seg_end_incl) return false;
+static inline bool RangeOverlaps(uptr beg, uptr end_excl, uptr seg_beg,
+                                 uptr seg_end_incl) {
+  if (!seg_beg && !seg_end_incl)
+    return false;
   uptr seg_end_excl = seg_end_incl + 1;
   return beg < seg_end_excl && end_excl > seg_beg;
 }
 
 static inline bool IntersectsShadowOrGap(uptr beg, uptr end_excl) {
   // Check shadow regions
-  if (RangeOverlaps(beg, end_excl, kLowShadowBeg, kLowShadowEnd)) return true;
-  if (kMidShadowBeg && RangeOverlaps(beg, end_excl, kMidShadowBeg, kMidShadowEnd)) return true;
-  if (RangeOverlaps(beg, end_excl, kHighShadowBeg, kHighShadowEnd)) return true;
+  if (RangeOverlaps(beg, end_excl, kLowShadowBeg, kLowShadowEnd))
+    return true;
+  if (kMidShadowBeg &&
+      RangeOverlaps(beg, end_excl, kMidShadowBeg, kMidShadowEnd))
+    return true;
+  if (RangeOverlaps(beg, end_excl, kHighShadowBeg, kHighShadowEnd))
+    return true;
 
   // Check shadow gaps
-  if (RangeOverlaps(beg, end_excl, kShadowGapBeg, kShadowGapEnd)) return true;
-  if (kShadowGap2Beg && RangeOverlaps(beg, end_excl, kShadowGap2Beg, kShadowGap2End)) return true;
-  if (kShadowGap3Beg && RangeOverlaps(beg, end_excl, kShadowGap3Beg, kShadowGap3End)) return true;
+  if (RangeOverlaps(beg, end_excl, kShadowGapBeg, kShadowGapEnd))
+    return true;
+  if (kShadowGap2Beg &&
+      RangeOverlaps(beg, end_excl, kShadowGap2Beg, kShadowGap2End))
+    return true;
+  if (kShadowGap3Beg &&
+      RangeOverlaps(beg, end_excl, kShadowGap3Beg, kShadowGap3End))
+    return true;
 
   return false;
 }
@@ -183,7 +195,7 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
     }
 
 template <class Mmap>
-static void *mmap_interceptor(Mmap real_mmap, void *addr, SIZE_T length,
+static void* mmap_interceptor(Mmap real_mmap, void* addr, SIZE_T length,
                               int prot, int flags, int fd, OFF64_T offset) {
   if (length == 0)
     return real_mmap(addr, length, prot, flags, fd, offset);
@@ -200,7 +212,7 @@ static void *mmap_interceptor(Mmap real_mmap, void *addr, SIZE_T length,
     if (__asan::IntersectsShadowOrGap(start, end_excl)) {
       errno = errno_EINVAL;
       GET_STACK_TRACE_FATAL_HERE;
-      ReportMmapShadowOverlap(start, end_excl, &stack);      
+      ReportMmapShadowOverlap(start, end_excl, &stack);
       if (common_flags()->abort_on_error) {
         Abort();
       }
@@ -264,18 +276,19 @@ static int munmap_interceptor(Munmap real_munmap, void *addr, SIZE_T length) {
   return res;
 }
 
-#  define COMMON_INTERCEPTOR_MMAP_IMPL(ctx, mmap, addr, length, prot, flags,   \
-                                     fd, offset)                               \
-  do {                                                                         \
-    (void)(ctx);                                                               \
-    return mmap_interceptor(REAL(mmap), addr, length, prot, flags, fd, offset);\
-  } while (false)
+#  define COMMON_INTERCEPTOR_MMAP_IMPL(ctx, mmap, addr, length, prot, flags, \
+                                       fd, offset)                           \
+    do {                                                                     \
+      (void)(ctx);                                                           \
+      return mmap_interceptor(REAL(mmap), addr, length, prot, flags, fd,     \
+                              offset);                                       \
+    } while (false)
 
-#  define COMMON_INTERCEPTOR_MUNMAP_IMPL(ctx, addr, length)                    \
-  do {                                                                         \
-    (void)(ctx);                                                               \
-    return munmap_interceptor(REAL(munmap), addr, length);                     \
-  } while (false)
+#  define COMMON_INTERCEPTOR_MUNMAP_IMPL(ctx, addr, length)  \
+    do {                                                     \
+      (void)(ctx);                                           \
+      return munmap_interceptor(REAL(munmap), addr, length); \
+    } while (false)
 
 #if CAN_SANITIZE_LEAKS
 #define COMMON_INTERCEPTOR_STRERROR()                       \
diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index fbefc63b4..53594b7b3 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -343,31 +343,33 @@ void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,
   in_report.ReportError(error);
 }
 
-void ReportMmapAddrOverflow(uptr start, uptr length, BufferedStackTrace *stack) {
+void ReportMmapAddrOverflow(uptr start, uptr length,
+                            BufferedStackTrace* stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorMmapAddrOverflow error(GetCurrentTidOrInvalid(), stack, start, length);
   in_report.ReportError(error);
 }
 
-void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack) {
+void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace* stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorMmapShadowOverlap error(GetCurrentTidOrInvalid(), stack, start, end);
   in_report.ReportError(error);
 }
 
-void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack) {
+void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace* stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorMmapOutsideRange error(GetCurrentTidOrInvalid(), stack, start, end);
   in_report.ReportError(error);
 }
 
-void ReportMunmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack) {
+void ReportMunmapShadowOverlap(uptr start, uptr end,
+                               BufferedStackTrace* stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorMunmapShadowOverlap error(GetCurrentTidOrInvalid(), stack, start, end);
   in_report.ReportError(error);
 }
 
-void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack) {
+void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace* stack) {
   ScopedInErrorReport in_report(/*fatal*/ true);
   ErrorMunmapOutsideRange error(GetCurrentTidOrInvalid(), stack, start, end);
   in_report.ReportError(error);
diff --git a/compiler-rt/lib/asan/asan_report.h b/compiler-rt/lib/asan/asan_report.h
index e7f653cf6..c50783fed 100644
--- a/compiler-rt/lib/asan/asan_report.h
+++ b/compiler-rt/lib/asan/asan_report.h
@@ -73,11 +73,11 @@ void ReportInvalidPosixMemalignAlignment(uptr alignment,
                                          BufferedStackTrace *stack);
 void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,
                                 BufferedStackTrace *stack);
-void ReportMmapAddrOverflow(uptr start, uptr length, BufferedStackTrace *stack);
-void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack);
-void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack);
-void ReportMunmapShadowOverlap(uptr start, uptr end, BufferedStackTrace *stack);
-void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace *stack);                                
+void ReportMmapAddrOverflow(uptr start, uptr length, BufferedStackTrace* stack);
+void ReportMmapShadowOverlap(uptr start, uptr end, BufferedStackTrace* stack);
+void ReportMmapOutsideRange(uptr start, uptr end, BufferedStackTrace* stack);
+void ReportMunmapShadowOverlap(uptr start, uptr end, BufferedStackTrace* stack);
+void ReportMunmapOutsideRange(uptr start, uptr end, BufferedStackTrace* stack);
 void ReportRssLimitExceeded(BufferedStackTrace *stack);
 void ReportOutOfMemory(uptr requested_size, BufferedStackTrace *stack);
 void ReportStringFunctionMemoryRangesOverlap(const char *function,
diff --git a/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp b/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
index 5833159f0..6c9229cfe 100644
--- a/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
+++ b/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
@@ -5,12 +5,13 @@
 #define ASAN_AIX_SHADOW_OFFSET 0x0a01000000000000ULL
 
 int main() {
-    size_t map_size = 4096;
-    void* addr = (void*)ASAN_AIX_SHADOW_OFFSET;
-    void* ptr = mmap(addr, map_size, PROT_READ | PROT_WRITE,
-                     MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
-    if (ptr != MAP_FAILED) munmap(ptr, map_size);
-    return 0;
+  size_t map_size = 4096;
+  void *addr = (void *)ASAN_AIX_SHADOW_OFFSET;
+  void *ptr = mmap(addr, map_size, PROT_READ | PROT_WRITE,
+                   MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+  if (ptr != MAP_FAILED)
+    munmap(ptr, map_size);
+  return 0;
 }
 
 // CHECK: ERROR: AddressSanitizer: mmap requested memory range

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 5818 tests passed
  • 1323 tests skipped
  • 4 tests failed

Failed Tests

(click on a test name to see its output)

AddressSanitizer-x86_64-linux

AddressSanitizer-x86_64-linux.TestCases/Linux/cuda_test.cpp
Exit Code: 1

Command Output (stderr):
--
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Linux/Output/cuda_test.cpp.tmp # RUN: at line 6
+ /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Linux/Output/cuda_test.cpp.tmp
not env ASAN_OPTIONS=protect_shadow_gap=1 /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Linux/Output/cuda_test.cpp.tmp 2>&1 | FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp  --check-prefix=CHECK-PROTECT1 # RUN: at line 7
+ not env ASAN_OPTIONS=protect_shadow_gap=1 /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Linux/Output/cuda_test.cpp.tmp
+ FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp --check-prefix=CHECK-PROTECT1
/home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp:28:21: error: CHECK-PROTECT1: expected string not found in input
 // CHECK-PROTECT1: AddressSanitizer: SEGV on unknown address 0x0000bfff8000
                    ^
<stdin>:1:1: note: scanning from here
=================================================================
^
<stdin>:2:18: note: possible intended match here
==456908==ERROR: AddressSanitizer: mmap requested memory range 0x200000000-0x1300000000 overlaps with ASan shadow memory
                 ^

Input file: <stdin>
Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ================================================================= 
check:28'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: ==456908==ERROR: AddressSanitizer: mmap requested memory range 0x200000000-0x1300000000 overlaps with ASan shadow memory 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:28'1                      ?                                                                                                        possible intended match
            3:  #0 0x58d520d66d08 in void* mmap_interceptor<void* (*)(void*, unsigned long, int, int, int, unsigned long long)>(void* (*)(void*, unsigned long, int, int, int, unsigned long long), void*, unsigned long, int, int, int, unsigned long long) /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:202:7 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4:  #1 0x58d520d668e9 in mmap /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:7681:3 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:  #2 0x58d520ddff69 in main /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp:21:7 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #3 0x7ea67837e1c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            7:  #4 0x7ea67837e28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

--

AddressSanitizer-x86_64-linux.TestCases/asan_mmap_oob_aix.cpp
Exit Code: 1

Command Output (stderr):
--
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  -O0 /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp && not  /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp 2>&1 | FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp # RUN: at line 1
+ /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -O0 /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp
+ not /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp
+ FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
/home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp:17:11: error: CHECK: expected string not found in input
// CHECK: overlaps with ASan shadow memory
          ^
<stdin>:2:63: note: scanning from here
==569899==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range
                                                              ^
<stdin>:2:119: note: possible intended match here
==569899==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range
                                                                                                                      ^

Input file: <stdin>
Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ================================================================= 
            2: ==569899==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range 
check:17'0                                                                   X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:17'1                                                                                                                           ?                                       possible intended match
            3:  #0 0x5d4bc9da402c in void* mmap_interceptor<void* (*)(void*, unsigned long, int, int, int, unsigned long long)>(void* (*)(void*, unsigned long, int, int, int, unsigned long long), void*, unsigned long, int, int, int, unsigned long long) /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:211:7 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4:  #1 0x5d4bc9da38d9 in mmap /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:7681:3 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:  #2 0x5d4bc9e1cf56 in main /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp:10:17 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #3 0x7c0a583371c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            7:  #4 0x7c0a5833728a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

--

AddressSanitizer-x86_64-linux-dynamic

AddressSanitizer-x86_64-linux-dynamic.TestCases/Linux/cuda_test.cpp
Exit Code: 1

Command Output (stderr):
--
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  -shared-libasan /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/cuda_test.cpp.tmp # RUN: at line 6
+ /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/cuda_test.cpp.tmp
not env ASAN_OPTIONS=protect_shadow_gap=1 /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/cuda_test.cpp.tmp 2>&1 | FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp  --check-prefix=CHECK-PROTECT1 # RUN: at line 7
+ FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp --check-prefix=CHECK-PROTECT1
+ not env ASAN_OPTIONS=protect_shadow_gap=1 /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/cuda_test.cpp.tmp
/home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp:28:21: error: CHECK-PROTECT1: expected string not found in input
 // CHECK-PROTECT1: AddressSanitizer: SEGV on unknown address 0x0000bfff8000
                    ^
<stdin>:1:1: note: scanning from here
=================================================================
^
<stdin>:2:18: note: possible intended match here
==464215==ERROR: AddressSanitizer: mmap requested memory range 0x200000000-0x1300000000 overlaps with ASan shadow memory
                 ^

Input file: <stdin>
Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ================================================================= 
check:28'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: ==464215==ERROR: AddressSanitizer: mmap requested memory range 0x200000000-0x1300000000 overlaps with ASan shadow memory 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:28'1                      ?                                                                                                        possible intended match
            3:  #0 0x7b0566ccd928 in void* mmap_interceptor<void* (*)(void*, unsigned long, int, int, int, unsigned long long)>(void* (*)(void*, unsigned long, int, int, int, unsigned long long), void*, unsigned long, int, int, int, unsigned long long) /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:202:7 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4:  #1 0x7b0566ccd509 in mmap /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:7681:3 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:  #2 0x564c347d95e9 in main /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp:21:7 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #3 0x7b05666351c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            7:  #4 0x7b056663528a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

--

AddressSanitizer-x86_64-linux-dynamic.TestCases/asan_mmap_oob_aix.cpp
Exit Code: 1

Command Output (stderr):
--
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  -shared-libasan -O0 /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp && not  /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp 2>&1 | FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp # RUN: at line 1
+ /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -O0 /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp
+ not /home/gha/actions-runner/_work/llvm-project/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_mmap_oob_aix.cpp.tmp
+ FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp
/home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp:17:11: error: CHECK: expected string not found in input
// CHECK: overlaps with ASan shadow memory
          ^
<stdin>:2:63: note: scanning from here
==569895==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range
                                                              ^
<stdin>:2:119: note: possible intended match here
==569895==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range
                                                                                                                      ^

Input file: <stdin>
Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ================================================================= 
            2: ==569895==ERROR: AddressSanitizer: mmap requested memory range 0xa01000000000000-0xa01000000001000 is outside ASan's instrumentable application memory range 
check:17'0                                                                   X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:17'1                                                                                                                           ?                                       possible intended match
            3:  #0 0x78e17be56c5c in void* mmap_interceptor<void* (*)(void*, unsigned long, int, int, int, unsigned long long)>(void* (*)(void*, unsigned long, int, int, int, unsigned long long), void*, unsigned long, int, int, int, unsigned long long) /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:211:7 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4:  #1 0x78e17be56509 in mmap /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:7681:3 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:  #2 0x55fe8804f5b6 in main /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/test/asan/TestCases/asan_mmap_oob_aix.cpp:10:17 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #3 0x78e17b7be1c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            7:  #4 0x78e17b7be28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e) 
check:17'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@honeygoyal honeygoyal marked this pull request as draft November 28, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants