[compiler-rt] r206470 - [asan] fix a bug in outlined asan checks and in the corresponding test (ouch)

Kostya Serebryany kcc at google.com
Thu Apr 17 07:38:25 PDT 2014


Author: kcc
Date: Thu Apr 17 09:38:25 2014
New Revision: 206470

URL: http://llvm.org/viewvc/llvm-project?rev=206470&view=rev
Log:
[asan] fix a bug in outlined asan checks and in the corresponding test (ouch)

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=206470&r1=206469&r2=206470&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Apr 17 09:38:25 2014
@@ -383,7 +383,7 @@ ASAN_REPORT_ERROR_N(store, true)
                                         : *reinterpret_cast<u16 *>(sp);        \
     if (s) {                                                                   \
       if (size >= SHADOW_GRANULARITY ||                                        \
-          (((addr & (SHADOW_GRANULARITY - 1)) + size - 1)) >= s) {             \
+          ((s8)((addr & (SHADOW_GRANULARITY - 1)) + size - 1)) >= (s8)s) {     \
         if (__asan_test_only_reported_buggy_pointer) {                         \
           *__asan_test_only_reported_buggy_pointer = addr;                     \
         } else {                                                               \

Modified: compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc?rev=206470&r1=206469&r2=206470&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc Thu Apr 17 09:38:25 2014
@@ -231,6 +231,7 @@ TEST(AddressSanitizer, LoadStoreCallback
   };
 
   uptr buggy_ptr;
+
   __asan_test_only_reported_buggy_pointer = &buggy_ptr;
   for (uptr len = 16; len <= 32; len++) {
     char *ptr = new char[len];
@@ -240,7 +241,7 @@ TEST(AddressSanitizer, LoadStoreCallback
         uptr size = 1 << size_log;
         CB call = cb[is_write][size_log];
         // Iterate only size-aligned offsets.
-        for (uptr offset = 0; offset < len; offset += size) {
+        for (uptr offset = 0; offset <= len; offset += size) {
           buggy_ptr = 0;
           call(p + offset);
           if (offset + size <= len)





More information about the llvm-commits mailing list