[compiler-rt] r316589 - [asan] Don't print rows of shadow bytes outside shadow memory
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 09:54:12 PDT 2017
Author: rnk
Date: Wed Oct 25 09:54:12 2017
New Revision: 316589
URL: http://llvm.org/viewvc/llvm-project?rev=316589&view=rev
Log:
[asan] Don't print rows of shadow bytes outside shadow memory
Summary:
They might not be mapped on some platforms such as Win64. In
particular, this happens if the user address is null. There will not be
any shadow memory 5*16 bytes before the user address. This happens on
Win64 in the error_report_callback.cc test case. It's not clear why this
isn't a problem on Linux as well.
Fixes PR35058
Reviewers: vitalybuka
Subscribers: kubamracek, llvm-commits
Differential Revision: https://reviews.llvm.org/D39260
Modified:
compiler-rt/trunk/lib/asan/asan_errors.cc
Modified: compiler-rt/trunk/lib/asan/asan_errors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_errors.cc?rev=316589&r1=316588&r2=316589&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_errors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_errors.cc Wed Oct 25 09:54:12 2017
@@ -422,9 +422,14 @@ static void PrintShadowMemoryForAddress(
InternalScopedString str(4096 * 8);
str.append("Shadow bytes around the buggy address:\n");
for (int i = -5; i <= 5; i++) {
+ uptr row_shadow_addr = aligned_shadow + i * n_bytes_per_row;
+ // Skip rows that would be outside the shadow range. This can happen when
+ // the user address is near the bottom, top, or shadow gap of the address
+ // space.
+ if (!AddrIsInShadow(row_shadow_addr)) continue;
const char *prefix = (i == 0) ? "=>" : " ";
- PrintShadowBytes(&str, prefix, (u8 *)(aligned_shadow + i * n_bytes_per_row),
- (u8 *)shadow_addr, n_bytes_per_row);
+ PrintShadowBytes(&str, prefix, (u8 *)row_shadow_addr, (u8 *)shadow_addr,
+ n_bytes_per_row);
}
if (flags()->print_legend) PrintLegend(&str);
Printf("%s", str.data());
More information about the llvm-commits
mailing list