[PATCH] D86168: [DFSan] Handle mmap() calls before interceptors are installed.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 15:00:01 PDT 2020


vitalybuka added inline comments.


================
Comment at: compiler-rt/lib/dfsan/dfsan_interceptors.cpp:23
 
+static bool interceptors_initialized;
+
----------------
vitalybuka wrote:
> morehouse wrote:
> > vitalybuka wrote:
> > > Have you considered EnsureInterceptorsInitialized from compiler-rt/lib/cfi/cfi.cpp or compiler-rt/lib/safestack/safestack.cpp
> > > I suspect it should not work as you can't do INTERCEPT_FUNCTION here
> > > 
> > > Anyway as is it's a data race, some synchronization is needed.
> > Initialization happens during preinit_array, when we're single-threaded.  The issue this solves is that initialization calls dlysm calls calloc calls mmap.  If we did lazy-initialization, we'd get infinite recursion.
> Interesting, I never considered that. Maybe it's relevant for other EnsureInterceptorsInitialized and we don't need locking there.
Also it's not true for !SANITIZER_CAN_USE_PREINIT_ARRAY.  I don't see any attempts to init dfsan without SANITIZER_CAN_USE_PREINIT_ARRAY, so I guess it's fine.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86168/new/

https://reviews.llvm.org/D86168



More information about the llvm-commits mailing list