[llvm-commits] [compiler-rt] r166029 - /compiler-rt/trunk/lib/asan/asan_mac.cc
Alexander Potapenko
glider at google.com
Tue Oct 16 09:58:10 PDT 2012
Author: glider
Date: Tue Oct 16 11:58:10 2012
New Revision: 166029
URL: http://llvm.org/viewvc/llvm-project?rev=166029&view=rev
Log:
Do not call ReplaceCFAllocator() before __CFInitialize(), otherwise crashes are possible on 10.8.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=122
Modified:
compiler-rt/trunk/lib/asan/asan_mac.cc
Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=166029&r1=166028&r2=166029&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Tue Oct 16 11:58:10 2012
@@ -131,7 +131,14 @@
}
void AsanPlatformThreadInit() {
- ReplaceCFAllocator();
+ // For the first program thread, we can't replace the allocator before
+ // __CFInitialize() has been called. If it hasn't, we'll call
+ // ReplaceCFAllocator() later on this thread.
+ // For other threads __CFInitialize() has been called before their creation.
+ // See also asan_malloc_mac.cc.
+ if (((CFRuntimeBase*)kCFAllocatorSystemDefault)->_cfisa) {
+ ReplaceCFAllocator();
+ }
}
AsanLock::AsanLock(LinkerInitialized) {
More information about the llvm-commits
mailing list