[llvm-commits] [compiler-rt] r166768 - /compiler-rt/trunk/lib/asan/asan_interceptors.cc

Alexander Potapenko glider at google.com
Fri Oct 26 04:31:14 PDT 2012


Author: glider
Date: Fri Oct 26 06:31:14 2012
New Revision: 166768

URL: http://llvm.org/viewvc/llvm-project?rev=166768&view=rev
Log:
In the dynamic runtime on Mac OS, do not call internal_strdup() before __asan_init().
This may result in a crash at startup.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=123.

Modified:
    compiler-rt/trunk/lib/asan/asan_interceptors.cc

Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=166768&r1=166767&r2=166768&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Fri Oct 26 06:31:14 2012
@@ -382,6 +382,14 @@
 
 #if ASAN_INTERCEPT_STRDUP
 INTERCEPTOR(char*, strdup, const char *s) {
+#if MAC_INTERPOSE_FUNCTIONS
+  // FIXME: because internal_strdup() uses InternalAlloc(), which currently
+  // just calls malloc() on Mac, we can't use internal_strdup() with the
+  // dynamic runtime. We can remove the call to REAL(strdup) once InternalAlloc
+  // starts using mmap() instead.
+  // See also http://code.google.com/p/address-sanitizer/issues/detail?id=123.
+  if (!asan_inited) return REAL(strdup)(s);
+#endif
   if (!asan_inited) return internal_strdup(s);
   ENSURE_ASAN_INITED();
   if (flags()->replace_str) {





More information about the llvm-commits mailing list