[PATCH] D14979: [asan] Correctly release memory allocated during early startup.

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 11:25:46 PST 2015


samsonov added inline comments.

================
Comment at: lib/asan/asan_malloc_linux.cc:33
@@ +32,3 @@
+static bool IsInCallocPool(const void *ptr) {
+  sptr off = (sptr)calloc_memory_for_dlsym - (sptr)ptr;
+  return 0 <= off && off < (sptr)kCallocPoolSize;
----------------
Wait, why is it not ptr - calloc_memory_for_dlsym?

================
Comment at: lib/asan/asan_malloc_linux.cc:74
@@ +73,3 @@
+    uptr offset = (uptr)calloc_memory_for_dlsym - (uptr)ptr;
+    uptr copy_size = Min(size, kCallocPoolSize - offset);
+    void *new_ptr = asan_malloc(size, &stack);
----------------
It's not that hard to keep sizes of the allocations from calloc_memory_for_dlsym. E.g. when you return `&calloc_memory_for_dlsym[allocated]` you can store `size_in_words` in `calloc_memory_for_dlsym_sizes[allocated]`.

================
Comment at: test/asan/TestCases/Linux/calloc-preload.c:10
@@ +9,3 @@
+// This way of setting LD_PRELOAD does not work with Android test runner.
+// REQUIRES: not-android
+
----------------
UNSUPPORTED: android
?


http://reviews.llvm.org/D14979





More information about the llvm-commits mailing list