[compiler-rt] c578508 - Revert "[compiler-rt][asan] Make wild-pointer crash error more useful"

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 19:14:17 PST 2021


Author: Vy Nguyen
Date: 2021-03-11T22:13:40-05:00
New Revision: c578508b5bb20ccce5e2a43dd2afc41a49afec74

URL: https://github.com/llvm/llvm-project/commit/c578508b5bb20ccce5e2a43dd2afc41a49afec74
DIFF: https://github.com/llvm/llvm-project/commit/c578508b5bb20ccce5e2a43dd2afc41a49afec74.diff

LOG: Revert "[compiler-rt][asan] Make wild-pointer crash error more useful"

This reverts commit f65e1aee4004c25fbeacd5024de1d17f0a7ebc5c.

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_descriptions.cpp
    compiler-rt/lib/asan/asan_descriptions.h

Removed: 
    compiler-rt/test/asan/TestCases/wild_pointer.cpp


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index 347eaa4a824f..153c874a4e77 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -77,6 +77,7 @@ static bool GetShadowKind(uptr addr, ShadowKind *shadow_kind) {
   } else if (AddrIsInLowShadow(addr)) {
     *shadow_kind = kShadowKindLow;
   } else {
+    CHECK(0 && "Address is not in memory and not in shadow?");
     return false;
   }
   return true;
@@ -463,13 +464,7 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
     return;
   }
   data.kind = kAddressKindWild;
-  data.wild.addr = addr;
-  data.wild.access_size = access_size;
-}
-
-void WildAddressDescription::Print() const {
-  Printf("Address %p is a wild pointer inside of access range of size %p.\n",
-         addr, access_size);
+  addr = 0;
 }
 
 void PrintAddressDescription(uptr addr, uptr access_size,

diff  --git a/compiler-rt/lib/asan/asan_descriptions.h b/compiler-rt/lib/asan/asan_descriptions.h
index 650e2eb9173a..ee0e2061559e 100644
--- a/compiler-rt/lib/asan/asan_descriptions.h
+++ b/compiler-rt/lib/asan/asan_descriptions.h
@@ -146,13 +146,6 @@ struct StackAddressDescription {
 bool GetStackAddressInformation(uptr addr, uptr access_size,
                                 StackAddressDescription *descr);
 
-struct WildAddressDescription {
-  uptr addr;
-  uptr access_size;
-
-  void Print() const;
-};
-
 struct GlobalAddressDescription {
   uptr addr;
   // Assume address is close to at most four globals.
@@ -200,7 +193,7 @@ class AddressDescription {
       HeapAddressDescription heap;
       StackAddressDescription stack;
       GlobalAddressDescription global;
-      WildAddressDescription wild;
+      uptr addr;
     };
   };
 
@@ -218,7 +211,7 @@ class AddressDescription {
   uptr Address() const {
     switch (data.kind) {
       case kAddressKindWild:
-        return data.wild.addr;
+        return data.addr;
       case kAddressKindShadow:
         return data.shadow.addr;
       case kAddressKindHeap:
@@ -233,7 +226,7 @@ class AddressDescription {
   void Print(const char *bug_descr = nullptr) const {
     switch (data.kind) {
       case kAddressKindWild:
-        data.wild.Print();
+        Printf("Address %p is a wild pointer.\n", data.addr);
         return;
       case kAddressKindShadow:
         return data.shadow.Print();

diff  --git a/compiler-rt/test/asan/TestCases/wild_pointer.cpp b/compiler-rt/test/asan/TestCases/wild_pointer.cpp
deleted file mode 100644
index 80c3e2b254e5..000000000000
--- a/compiler-rt/test/asan/TestCases/wild_pointer.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx_asan %s -o %t
-// RUN: not %run %t 2>&1 | FileCheck %s
-// REQUIRES: asan-64-bits
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-
-int main() {
-  char *p = new char;
-  char *dest = new char;
-  const size_t offset = 0x4567890123456789;
-  // Flush it so the output came out before the asan report.
-  fprintf(stderr, "Expected bad addr: %p\n", p + offset);
-  fflush(stderr);
-  memmove(dest, p, offset);
-  return 0;
-}
-
-// CHECK: Expected bad addr: [[ADDR:0x[0-9,a-f]+]]
-// CHECK: AddressSanitizer: unknown-crash on address [[ADDR]]
-// CHECK: Address [[ADDR]] is a wild pointer inside of access range of size 0x4567890123456789


        


More information about the llvm-commits mailing list