[PATCH] [ASan] Add use_madv_dontdump flag.
Yury Gribov
tetra2005 at gmail.com
Fri Jan 30 05:57:51 PST 2015
Hi kcc, samsonov,
This patch implements use_madv_dontdump flag suggested in https://code.google.com/p/address-sanitizer/issues/detail?id=345 . The flag disables dumping of shadow memory to corefile (which takes hours on 64-bit platforms). Tested on Linux x64.
I didn't add a testcase - generating a predictable corefile is hard given the zoo of modern crash reporters. E.g. see https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1346497 (Apport from stock Ubuntu 14 multiples core limit by 1000).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7294
Files:
lib/asan/asan_flags.inc
lib/asan/asan_rtl.cc
lib/sanitizer_common/sanitizer_common.h
lib/sanitizer_common/sanitizer_posix_libcdep.cc
lib/sanitizer_common/sanitizer_win.cc
Index: lib/asan/asan_flags.inc
===================================================================
--- lib/asan/asan_flags.inc
+++ lib/asan/asan_flags.inc
@@ -77,6 +77,9 @@
"295.*.")
ASAN_FLAG(bool, unmap_shadow_on_exit, false,
"If set, explicitly unmaps the (huge) shadow at exit.")
+ASAN_FLAG(bool, use_madv_dontdump, true,
+ "If set, instructs kernel to not store the (huge) shadow "
+ "in core file.")
ASAN_FLAG(
bool, abort_on_error, false,
"If set, the tool calls abort() instead of _exit() after printing the "
Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -100,6 +100,8 @@
}
if (common_flags()->no_huge_pages_for_shadow)
NoHugePagesInRegion(beg, size);
+ if (flags()->use_madv_dontdump)
+ DontDumpShadowMemory(beg, size);
}
// --------------- LowLevelAllocateCallbac ---------- {{{1
Index: lib/sanitizer_common/sanitizer_common.h
===================================================================
--- lib/sanitizer_common/sanitizer_common.h
+++ lib/sanitizer_common/sanitizer_common.h
@@ -77,6 +77,7 @@
void DecreaseTotalMmap(uptr size);
uptr GetRSS();
void NoHugePagesInRegion(uptr addr, uptr length);
+void DontDumpShadowMemory(uptr addr, uptr length);
// InternalScopedBuffer can be used instead of large stack arrays to
// keep frame size low.
Index: lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -50,6 +50,12 @@
#endif // MADV_NOHUGEPAGE
}
+void DontDumpShadowMemory(uptr addr, uptr length) {
+#ifdef MADV_DONTDUMP
+ madvise((void *)addr, length, MADV_DONTDUMP);
+#endif
+}
+
static rlim_t getlim(int res) {
rlimit rlim;
CHECK_EQ(0, getrlimit(res, &rlim));
Index: lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- lib/sanitizer_common/sanitizer_win.cc
+++ lib/sanitizer_common/sanitizer_win.cc
@@ -129,13 +129,18 @@
void FlushUnneededShadowMemory(uptr addr, uptr size) {
// This is almost useless on 32-bits.
- // FIXME: add madvice-analog when we move to 64-bits.
+ // FIXME: add madvise-analog when we move to 64-bits.
}
void NoHugePagesInRegion(uptr addr, uptr size) {
// FIXME: probably similar to FlushUnneededShadowMemory.
}
+void DontDumpShadowMemory(uptr addr, uptr length) {
+ // This is almost useless on 32-bits.
+ // FIXME: add madvise-analog when we move to 64-bits.
+}
+
bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) {
MEMORY_BASIC_INFORMATION mbi;
CHECK(VirtualQuery((void *)range_start, &mbi, sizeof(mbi)));
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7294.19035.patch
Type: text/x-patch
Size: 2812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/c27f67dd/attachment.bin>
More information about the llvm-commits
mailing list