[compiler-rt] r272870 - [esan] Use internal_mmap during initialization

Derek Bruening via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 20:19:59 PDT 2016


Author: bruening
Date: Wed Jun 15 22:19:58 2016
New Revision: 272870

URL: http://llvm.org/viewvc/llvm-project?rev=272870&view=rev
Log:
[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.

Modified:
    compiler-rt/trunk/lib/esan/esan_interceptors.cpp

Modified: compiler-rt/trunk/lib/esan/esan_interceptors.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/esan_interceptors.cpp?rev=272870&r1=272869&r2=272870&view=diff
==============================================================================
--- compiler-rt/trunk/lib/esan/esan_interceptors.cpp (original)
+++ compiler-rt/trunk/lib/esan/esan_interceptors.cpp Wed Jun 15 22:19:58 2016
@@ -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))




More information about the llvm-commits mailing list