[llvm-commits] [compiler-rt] r146075 - in /compiler-rt/trunk/lib/asan: asan_rtl.cc tests/asan_test.cc
Kostya Serebryany
kcc at google.com
Wed Dec 7 13:30:21 PST 2011
Author: kcc
Date: Wed Dec 7 15:30:20 2011
New Revision: 146075
URL: http://llvm.org/viewvc/llvm-project?rev=146075&view=rev
Log:
[asan] fix the error message for 16-byte accesses (it previously printed 'unknown-crash')
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/tests/asan_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=146075&r1=146074&r2=146075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Dec 7 15:30:20 2011
@@ -556,12 +556,13 @@
const char *bug_descr = "unknown-crash";
if (AddrIsInMem(addr)) {
uint8_t *shadow_addr = (uint8_t*)MemToShadow(addr);
- uint8_t shadow_byte = shadow_addr[0];
- if (shadow_byte > 0 && shadow_byte < 128) {
- // we are in the partial right redzone, look at the next shadow byte.
- shadow_byte = shadow_addr[1];
- }
- switch (shadow_byte) {
+ // If we are accessing 16 bytes, look at the second shadow byte.
+ if (*shadow_addr == 0 && access_size > SHADOW_GRANULARITY)
+ shadow_addr++;
+ // If we are in the partial right redzone, look at the next shadow byte.
+ if (*shadow_addr > 0 && *shadow_addr < 128)
+ shadow_addr++;
+ switch (*shadow_addr) {
case kAsanHeapLeftRedzoneMagic:
case kAsanHeapRightRedzoneMagic:
bug_descr = "heap-buffer-overflow";
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=146075&r1=146074&r2=146075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Wed Dec 7 15:30:20 2011
@@ -833,6 +833,8 @@
assert(((uintptr_t)p % 16) == 0);
__m128i value_wide = _mm_set1_epi16(0x1234);
EXPECT_DEATH(_mm_store_si128((__m128i*)p, value_wide),
+ "AddressSanitizer heap-buffer-overflow");
+ EXPECT_DEATH(_mm_store_si128((__m128i*)p, value_wide),
"WRITE of size 16");
EXPECT_DEATH(_mm_store_si128((__m128i*)p, value_wide),
"located 0 bytes to the right of 12-byte");
More information about the llvm-commits
mailing list