diff options
author | Alexander Potapenko <glider@google.com> | 2013-03-26 10:34:37 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2013-03-26 10:34:37 +0000 |
commit | f8109dd0f8fb807dfb44353c175a2262fa4e8929 (patch) | |
tree | b54266908326ea90876d9d27ac072f79c0bcdf0a /compiler-rt/lib/sanitizer_common/sanitizer_linux.cc | |
parent | 90b45124cdb383e6b2b813d57e2eefc0caa985fc (diff) | |
download | bcm5719-llvm-f8109dd0f8fb807dfb44353c175a2262fa4e8929.tar.gz bcm5719-llvm-f8109dd0f8fb807dfb44353c175a2262fa4e8929.zip |
[libsanitizer] Unmapping the old cache partially invalidates the memory layout, so add
a flag to skip cache update for cases when that's unacceptable (e.g. lsan).
Patch by Sergey Matveev (earthdok@google.com)
llvm-svn: 178000
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_linux.cc')
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 901d76bddc0..97db9e78b39 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -200,7 +200,7 @@ void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, CHECK_EQ(getrlimit(RLIMIT_STACK, &rl), 0); // Find the mapping that contains a stack variable. - MemoryMappingLayout proc_maps; + MemoryMappingLayout proc_maps(/*cache_enabled*/true); uptr start, end, offset; uptr prev_end = 0; while (proc_maps.Next(&start, &end, &offset, 0, 0, /* protection */0)) { @@ -341,18 +341,22 @@ void PrepareForSandboxing() { ProcSelfMapsBuff MemoryMappingLayout::cached_proc_self_maps_; StaticSpinMutex MemoryMappingLayout::cache_lock_; // Linker initialized. -MemoryMappingLayout::MemoryMappingLayout() { +MemoryMappingLayout::MemoryMappingLayout(bool cache_enabled) { proc_self_maps_.len = ReadFileToBuffer("/proc/self/maps", &proc_self_maps_.data, &proc_self_maps_.mmaped_size, 1 << 26); - if (proc_self_maps_.mmaped_size == 0) { - LoadFromCache(); - CHECK_GT(proc_self_maps_.len, 0); + if (cache_enabled) { + if (proc_self_maps_.mmaped_size == 0) { + LoadFromCache(); + CHECK_GT(proc_self_maps_.len, 0); + } + } else { + CHECK_GT(proc_self_maps_.mmaped_size, 0); } - // internal_write(2, proc_self_maps_.data, proc_self_maps_.len); Reset(); // FIXME: in the future we may want to cache the mappings on demand only. - CacheMemoryMappings(); + if (cache_enabled) + CacheMemoryMappings(); } MemoryMappingLayout::~MemoryMappingLayout() { @@ -643,7 +647,6 @@ int internal_sigaltstack(const struct sigaltstack *ss, return syscall(__NR_sigaltstack, ss, oss); } - // ThreadLister implementation. ThreadLister::ThreadLister(int pid) : pid_(pid), |