[compiler-rt] r227803 - [ASan/Win] Add some diagnostics to help investigate Mprotect failures
Timur Iskhodzhanov
timurrrr at google.com
Mon Feb 2 07:04:24 PST 2015
Author: timurrrr
Date: Mon Feb 2 09:04:23 2015
New Revision: 227803
URL: http://llvm.org/viewvc/llvm-project?rev=227803&view=rev
Log:
[ASan/Win] Add some diagnostics to help investigate Mprotect failures
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.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=227803&r1=227802&r2=227803&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Feb 2 09:04:23 2015
@@ -245,7 +245,13 @@ static void InitializeHighMemEnd() {
}
static void ProtectGap(uptr a, uptr size) {
- CHECK_EQ(a, (uptr)Mprotect(a, size));
+ void *res = Mprotect(a, size);
+ if (a == (uptr)res)
+ return;
+ Report("ERROR: Failed to protect the shadow gap. "
+ "ASan cannot proceed correctly. ABORTING.\n");
+ DumpProcessMap();
+ Die();
}
static void PrintAddressSpaceLayout() {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=227803&r1=227802&r2=227803&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Mon Feb 2 09:04:23 2015
@@ -123,8 +123,13 @@ void *MmapNoReserveOrDie(uptr size, cons
}
void *Mprotect(uptr fixed_addr, uptr size) {
- return VirtualAlloc((LPVOID)fixed_addr, size,
- MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
+ void *res = VirtualAlloc((LPVOID)fixed_addr, size,
+ MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
+ if (res == 0)
+ Report("WARNING: %s failed to "
+ "mprotect %p (%zd) bytes at %p (error code: %d)\n",
+ SanitizerToolName, size, size, fixed_addr, GetLastError());
+ return res;
}
void FlushUnneededShadowMemory(uptr addr, uptr size) {
@@ -139,7 +144,7 @@ void NoHugePagesInRegion(uptr addr, uptr
bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) {
MEMORY_BASIC_INFORMATION mbi;
CHECK(VirtualQuery((void *)range_start, &mbi, sizeof(mbi)));
- return mbi.Protect & PAGE_NOACCESS &&
+ return mbi.Protect == PAGE_NOACCESS &&
(uptr)mbi.BaseAddress + mbi.RegionSize >= range_end;
}
More information about the llvm-commits
mailing list