summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2012-10-26 11:31:14 +0000
committerAlexander Potapenko <glider@google.com>2012-10-26 11:31:14 +0000
commit71578faf4eb8e61aefb3121e1945cc47f07cea0d (patch)
treeac94f960ae0142872ef53b136655551bffcf8ce7
parenteda8bd0fc07df35c9ad7de5b698bb717b063e7af (diff)
downloadcompiler-rt-71578faf4eb8e61aefb3121e1945cc47f07cea0d.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166768 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/asan_interceptors.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index d679863ea..48dfeb001 100644
--- a/lib/asan/asan_interceptors.cc
+++ b/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) {