From ed4063874ac289bc42a04347853716bb8b74f9de Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Thu, 16 Jun 2016 03:19:58 +0000 Subject: [esan] Use internal_mmap during initialization Fixes another interceptor issue where an app with a static tcmalloc library that prevents our early-calloc handling from triggering yet does not have a static mmap crashes in our mmap interceptor. The solution is to call internal_mmap when REAL(mmap) is not yet set up. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272870 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/esan/esan_interceptors.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/esan') diff --git a/lib/esan/esan_interceptors.cpp b/lib/esan/esan_interceptors.cpp index 7aefeb664..188336bed 100644 --- a/lib/esan/esan_interceptors.cpp +++ b/lib/esan/esan_interceptors.cpp @@ -338,6 +338,12 @@ INTERCEPTOR(int, rmdir, char *path) { INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags, int fd, OFF_T off) { + if (UNLIKELY(REAL(mmap) == nullptr)) { + // With esan init during interceptor init and a static libc preventing + // our early-calloc from triggering, we can end up here before our + // REAL pointer is set up. + return (void *)internal_mmap(addr, sz, prot, flags, fd, off); + } void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, mmap, addr, sz, prot, flags, fd, off); if (!fixMmapAddr(&addr, sz, flags)) -- cgit v1.2.3