Skip to content

Commit 03d02a0

Browse files
committedOct 25, 2017
[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 llvm-svn: 316589
1 parent 47e093d commit 03d02a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎compiler-rt/lib/asan/asan_errors.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,14 @@ static void PrintShadowMemoryForAddress(uptr addr) {
422422
InternalScopedString str(4096 * 8);
423423
str.append("Shadow bytes around the buggy address:\n");
424424
for (int i = -5; i <= 5; i++) {
425+
uptr row_shadow_addr = aligned_shadow + i * n_bytes_per_row;
426+
// Skip rows that would be outside the shadow range. This can happen when
427+
// the user address is near the bottom, top, or shadow gap of the address
428+
// space.
429+
if (!AddrIsInShadow(row_shadow_addr)) continue;
425430
const char *prefix = (i == 0) ? "=>" : " ";
426-
PrintShadowBytes(&str, prefix, (u8 *)(aligned_shadow + i * n_bytes_per_row),
427-
(u8 *)shadow_addr, n_bytes_per_row);
431+
PrintShadowBytes(&str, prefix, (u8 *)row_shadow_addr, (u8 *)shadow_addr,
432+
n_bytes_per_row);
428433
}
429434
if (flags()->print_legend) PrintLegend(&str);
430435
Printf("%s", str.data());

0 commit comments

Comments
 (0)
Please sign in to comment.