[llvm-commits] [compiler-rt] r146231 - in /compiler-rt/trunk/lib/asan: asan_allocator.cc asan_allocator.h asan_rtl.cc
Kostya Serebryany
kcc at google.com
Thu Dec 8 17:49:31 PST 2011
Author: kcc
Date: Thu Dec 8 19:49:31 2011
New Revision: 146231
URL: http://llvm.org/viewvc/llvm-project?rev=146231&view=rev
Log:
[asan] make use-after-return mode more robust: allow to call instrumented functions while reporting an error
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_allocator.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=146231&r1=146230&r2=146231&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Thu Dec 8 19:49:31 2011
@@ -869,7 +869,6 @@
}
uintptr_t FakeStack::AddrIsInFakeStack(uintptr_t addr) {
- if (!alive_) return 0;
for (size_t i = 0; i < kNumberOfSizeClasses; i++) {
if (AddrIsInSizeClass(addr, i)) return allocated_size_classes_[i];
}
@@ -959,7 +958,7 @@
}
uintptr_t FakeStack::AllocateStack(size_t size, size_t real_stack) {
- CHECK(alive_);
+ if (!alive_) return real_stack;
CHECK(size <= kMaxStackMallocSize && size > 1);
size_t size_class = ComputeSizeClass(size);
if (!allocated_size_classes_[size_class]) {
Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=146231&r1=146230&r2=146231&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Thu Dec 8 19:49:31 2011
@@ -101,6 +101,7 @@
FakeStack();
explicit FakeStack(LinkerInitialized) {}
void Init(size_t stack_size);
+ void StopUsingFakeStack() { alive_ = false; }
void Cleanup();
uintptr_t AllocateStack(size_t size, size_t real_stack);
static void OnFree(size_t ptr, size_t size, size_t real_stack);
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=146231&r1=146230&r2=146231&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Dec 8 19:49:31 2011
@@ -586,13 +586,22 @@
}
}
+ AsanThread *curr_thread = asanThreadRegistry().GetCurrent();
+ int curr_tid = asanThreadRegistry().GetCurrentTidOrMinusOne();
+
+ if (curr_thread) {
+ // We started reporting an error message. Stop using the fake stack
+ // in case we will call an instrumented function from a symbolizer.
+ curr_thread->fake_stack().StopUsingFakeStack();
+ }
+
Report("ERROR: AddressSanitizer %s on address "
"%p at pc 0x%lx bp 0x%lx sp 0x%lx\n",
bug_descr, addr, pc, bp, sp);
Printf("%s of size %d at %p thread T%d\n",
access_size ? (is_write ? "WRITE" : "READ") : "ACCESS",
- access_size, addr, asanThreadRegistry().GetCurrentTidOrMinusOne());
+ access_size, addr, curr_tid);
if (FLAG_debug) {
PrintBytes("PC: ", (uintptr_t*)pc);
More information about the llvm-commits
mailing list