[compiler-rt] r178000 - [libsanitizer] Unmapping the old cache partially invalidates the memory layout, so add
Alexey Samsonov
samsonov at google.com
Tue Mar 26 04:36:06 PDT 2013
Windows bot barks:
../sanitizer_common/sanitizer_stacktrace.cc(67) : error C2664:
'__sanitizer::MemoryMappingLayout::MemoryMappingLayout(const
__sanitizer::MemoryMappingLayout &)' : cannot convert parameter 1 from
'bool' to 'const __sanitizer::MemoryMappingLayout &'
Reason: cannot convert from 'bool' to 'const
__sanitizer::MemoryMappingLayout'
No constructor could take the source type, or constructor
overload resolution was ambiguous
On Tue, Mar 26, 2013 at 2:34 PM, Alexander Potapenko <glider at google.com>wrote:
> Author: glider
> Date: Tue Mar 26 05:34:37 2013
> New Revision: 178000
>
> URL: http://llvm.org/viewvc/llvm-project?rev=178000&view=rev
> Log:
> [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 at google.com)
>
>
> Modified:
> compiler-rt/trunk/lib/msan/msan.cc
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
>
> Modified: compiler-rt/trunk/lib/msan/msan.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/msan/msan.cc (original)
> +++ compiler-rt/trunk/lib/msan/msan.cc Tue Mar 26 05:34:37 2013
> @@ -70,7 +70,7 @@ namespace __msan {
>
> static bool IsRunningUnderDr() {
> bool result = false;
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(/*cache_enabled*/true);
> const sptr kBufSize = 4095;
> char *filename = (char*)MmapOrDie(kBufSize, __FUNCTION__);
> while (proc_maps.Next(/* start */0, /* end */0, /* file_offset */0,
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Mar 26
> 05:34:37 2013
> @@ -200,7 +200,7 @@ void GetThreadStackTopAndBottom(bool at_
> 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 si
> return syscall(__NR_sigaltstack, ss, oss);
> }
>
> -
> // ThreadLister implementation.
> ThreadLister::ThreadLister(int pid)
> : pid_(pid),
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Tue Mar 26
> 05:34:37 2013
> @@ -165,7 +165,7 @@ void PrepareForSandboxing() {
>
> // ----------------- sanitizer_procmaps.h
>
> -MemoryMappingLayout::MemoryMappingLayout() {
> +MemoryMappingLayout::MemoryMappingLayout(bool cache_enabled) {
> Reset();
> }
>
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Tue Mar 26
> 05:34:37 2013
> @@ -151,11 +151,11 @@ static inline bool IntervalsAreSeparate(
> // several worker threads on Mac, which aren't expected to map big chunks
> of
> // memory).
> bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) {
> - MemoryMappingLayout procmaps;
> + MemoryMappingLayout proc_maps(/*cache_enabled*/true);
> uptr start, end;
> - while (procmaps.Next(&start, &end,
> - /*offset*/0, /*filename*/0, /*filename_size*/0,
> - /*protection*/0)) {
> + while (proc_maps.Next(&start, &end,
> + /*offset*/0, /*filename*/0, /*filename_size*/0,
> + /*protection*/0)) {
> if (!IntervalsAreSeparate(start, end, range_start, range_end))
> return false;
> }
> @@ -163,7 +163,7 @@ bool MemoryRangeIsAvailable(uptr range_s
> }
>
> void DumpProcessMap() {
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(/*cache_enabled*/true);
> uptr start, end;
> const sptr kBufSize = 4095;
> char *filename = (char*)MmapOrDie(kBufSize, __FUNCTION__);
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h Tue Mar 26
> 05:34:37 2013
> @@ -41,7 +41,7 @@ struct ProcSelfMapsBuff {
>
> class MemoryMappingLayout {
> public:
> - MemoryMappingLayout();
> + explicit MemoryMappingLayout(bool cache_enabled);
> bool Next(uptr *start, uptr *end, uptr *offset,
> char filename[], uptr filename_size, uptr *protection);
> void Reset();
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
> (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Tue Mar
> 26 05:34:37 2013
> @@ -64,7 +64,7 @@ static void PrintModuleAndOffset(const c
> void StackTrace::PrintStack(const uptr *addr, uptr size,
> bool symbolize, const char *strip_file_prefix,
> SymbolizeCallback symbolize_callback ) {
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(/*cache_enabled*/true);
> InternalScopedBuffer<char> buff(GetPageSizeCached() * 2);
> InternalScopedBuffer<AddressInfo> addr_frames(64);
> uptr frame_num = 0;
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=178000&r1=177999&r2=178000&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Tue Mar 26
> 05:34:37 2013
> @@ -198,7 +198,7 @@ static void MapRodata() {
> return;
> }
> // Map the file into shadow of .rodata sections.
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(/*cache_enabled*/true);
> uptr start, end, offset, prot;
> char name[128];
> while (proc_maps.Next(&start, &end, &offset, name, ARRAY_SIZE(name),
> &prot)) {
> @@ -257,7 +257,7 @@ static uptr g_data_end;
> #ifndef TSAN_GO
> static void CheckPIE() {
> // Ensure that the binary is indeed compiled with -pie.
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(true);
> uptr start, end;
> if (proc_maps.Next(&start, &end,
> /*offset*/0, /*filename*/0, /*filename_size*/0,
> @@ -274,7 +274,7 @@ static void CheckPIE() {
> }
>
> static void InitDataSeg() {
> - MemoryMappingLayout proc_maps;
> + MemoryMappingLayout proc_maps(true);
> uptr start, end, offset;
> char name[128];
> bool prev_is_data = false;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130326/c50020ed/attachment.html>
More information about the llvm-commits
mailing list