[PATCH] D21086: [esan] Intercept calloc to avoid deadlocks with tcmalloc

Derek Bruening via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 15:22:47 PDT 2016


bruening added inline comments.

================
Comment at: lib/esan/esan_interceptors.cpp:431
@@ +430,3 @@
+  CHECK(!used_early_alloc_buf && size < sizeof(early_alloc_buf));
+  used_early_alloc_buf = true;
+  return (void *)early_alloc_buf;
----------------
aizatsky wrote:
> Is there a multi-threading concern here? I assume tcmalloc initializes in one thread only?
This will only happen at process init prior to __esan_init, but I suppose it's possible for some shared library to create early threads that all race here.  Given the fragility of sanitizer libc interceptors in general I'd have to say that's not high on my list of corner cases to worry about.  Are you ok with a comment saying we simply don't handle it?

================
Comment at: lib/esan/esan_interceptors.cpp:450
@@ +449,3 @@
+  if (p == (void *)early_alloc_buf)
+    return;
+  REAL(free)(p);
----------------
aizatsky wrote:
> Do you want to clear used_early_alloc_buf here?
Sure, for cleanliness, though we do not expect it to matter (we expect a single call to calloc during dlsym prior to REAL(calloc) being set and after that to never need the buffer again).


http://reviews.llvm.org/D21086





More information about the llvm-commits mailing list