[PATCH] D47501: [asan, myriad] Reset shadow memory during exit
Walter Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 15:07:27 PDT 2018
waltl created this revision.
waltl added reviewers: vitalybuka, eugenis, alekseyshl.
Herald added a subscriber: kubamracek.
Reset shadow memory during exit. Also update a cut-and-paste comment,
and do some minor refactoring of InitializeShadowMemory.
Repository:
rL LLVM
https://reviews.llvm.org/D47501
Files:
compiler-rt/lib/asan/asan_rtems.cc
Index: compiler-rt/lib/asan/asan_rtems.cc
===================================================================
--- compiler-rt/lib/asan/asan_rtems.cc
+++ compiler-rt/lib/asan/asan_rtems.cc
@@ -29,21 +29,24 @@
namespace __asan {
-void InitializeShadowMemory() {
- kHighMemEnd = 0;
- kMidMemBeg = 0;
- kMidMemEnd = 0;
-
+static void ResetShadowMemory() {
uptr shadow_start = SHADOW_OFFSET;
uptr shadow_end = MEM_TO_SHADOW(kMyriadMemoryEnd32);
- uptr shadow_size = shadow_end - shadow_start;
uptr gap_start = MEM_TO_SHADOW(shadow_start);
uptr gap_end = MEM_TO_SHADOW(shadow_end);
- REAL(memset)((void *)shadow_start, 0, shadow_size);
+ REAL(memset)((void *)shadow_start, 0, shadow_end - shadow_start);
REAL(memset)((void *)gap_start, kAsanShadowGap, gap_end - gap_start);
}
+void InitializeShadowMemory() {
+ kHighMemEnd = 0;
+ kMidMemBeg = 0;
+ kMidMemEnd = 0;
+
+ ResetShadowMemory();
+}
+
void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
UNIMPLEMENTED();
}
@@ -66,7 +69,7 @@
// Provide early initialization of shadow memory so that
// instrumented code running before full initialzation will not
// report spurious errors.
- InitializeShadowMemory();
+ ResetShadowMemory();
}
// Main thread information. Initialized in CreateMainThread() and
@@ -118,10 +121,8 @@
}
// This gets the same arguments passed to Init by CreateAsanThread, above.
-// We're in the creator thread before the new thread is actually started,
-// but its stack address range is already known. We don't bother tracking
-// the static TLS address range because the system itself already uses an
-// ASan-aware allocator for that.
+// We're in the creator thread before the new thread is actually started, but
+// its stack and tls address range are already known.
void AsanThread::SetThreadStackAndTls(const AsanThread::InitOptions *options) {
DCHECK_NE(GetCurrentThread(), this);
DCHECK_NE(GetCurrentThread(), nullptr);
@@ -220,7 +221,7 @@
// shadow memory to avoid reporting errors after the run-time has
// been desroyed.
asan_inited = false;
- // InitializeShadowMemory();
+ ResetShadowMemory();
}
} // namespace __asan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47501.148992.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180529/f6df0b64/attachment.bin>
More information about the llvm-commits
mailing list