From 99843d3a2990f26ea6c90b66221745fde33bc4b7 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Fri, 26 Oct 2012 11:31:14 +0000 Subject: [PATCH] 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. llvm-svn: 166768 --- compiler-rt/lib/asan/asan_interceptors.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc index d679863..48dfeb0 100644 --- a/compiler-rt/lib/asan/asan_interceptors.cc +++ b/compiler-rt/lib/asan/asan_interceptors.cc @@ -382,6 +382,14 @@ INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT #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) { -- 2.7.4