[compiler-rt] r282389 - [asan, msan] Fix reallocation logic when IsInDlsymAllocPool(ptr) is true.
Maxim Ostapenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 01:11:21 PDT 2016
Author: chefmax
Date: Mon Sep 26 03:11:21 2016
New Revision: 282389
URL: http://llvm.org/viewvc/llvm-project?rev=282389&view=rev
Log:
[asan, msan] Fix reallocation logic when IsInDlsymAllocPool(ptr) is true.
Modified:
compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
compiler-rt/trunk/lib/msan/msan_interceptors.cc
Modified: compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_linux.cc?rev=282389&r1=282388&r2=282389&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_linux.cc Mon Sep 26 03:11:21 2016
@@ -79,10 +79,12 @@ INTERCEPTOR(void*, realloc, void *ptr, u
uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
uptr copy_size = Min(size, kDlsymAllocPoolSize - offset);
void *new_ptr;
- if (UNLIKELY(!asan_inited))
+ if (UNLIKELY(!asan_inited)) {
new_ptr = AllocateFromLocalPool(size);
- else
- new_ptr = asan_malloc(size, &stack);
+ } else {
+ copy_size = size;
+ new_ptr = asan_malloc(copy_size, &stack);
+ }
internal_memcpy(new_ptr, ptr, copy_size);
return new_ptr;
}
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=282389&r1=282388&r2=282389&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Mon Sep 26 03:11:21 2016
@@ -935,7 +935,13 @@ INTERCEPTOR(void *, realloc, void *ptr,
if (UNLIKELY(IsInDlsymAllocPool(ptr))) {
uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
uptr copy_size = Min(size, kDlsymAllocPoolSize - offset);
- void *new_ptr = AllocateFromLocalPool(size);
+ void *new_ptr;
+ if (UNLIKELY(!msan_inited)) {
+ new_ptr = AllocateFromLocalPool(copy_size);
+ } else {
+ copy_size = size;
+ new_ptr = MsanReallocate(&stack, ptr, copy_size, sizeof(u64), false);
+ }
internal_memcpy(new_ptr, ptr, copy_size);
return new_ptr;
}
More information about the llvm-commits
mailing list