[llvm-commits] [PATCH] [ASan] Use dylib interposition to hook memory allocation in the dynamic runtime.

Alexey Samsonov samsonov at google.com
Tue Dec 18 05:34:45 PST 2012



================
Comment at: asan_intercepted_functions.h:232
@@ +231,3 @@
+typedef void malloc_zone_t;
+typedef size_t vm_size_t;
+DECLARE_FUNCTION_AND_WRAPPER(malloc_zone_t *, malloc_create_zone,
----------------
Hm, can you use uptr instead of size_t?

================
Comment at: asan_malloc_mac.cc:87
@@ +86,3 @@
+    GET_STACK_TRACE_MALLOC;
+    new_name = (char*)asan_malloc(buflen, &stack);
+    if (new_name) {
----------------
Why do you need to allocate/free memory for zone name via ASan allocator (with fetching stack trace for malloc etc.)
Can you use InternalScopedBuffer instead?

================
Comment at: asan_malloc_mac.cc:109
@@ +108,3 @@
+  void *res = asan_malloc(size, &stack);
+  ///Report("malloc(%d)=%p\n", size, res);
+  return res;
----------------
Remove this (or hide under verbosity?)

================
Comment at: asan_malloc_mac.cc:149
@@ +148,3 @@
+  if (result) {
+    *memptr = result;
+    return 0;
----------------
Can memptr be zero? Or it's fine to segfault in this case?

================
Comment at: asan_malloc_mac.cc:204
@@ +203,3 @@
+  GET_STACK_TRACE_FREE;
+  // FIXME: need to retire this flag.
+  if (!flags()->mac_ignore_invalid_free) {
----------------
Why? (just curious)

================
Comment at: lit_tests/heap-overflow.cc:32
@@ -31,5 +31,3 @@
 
-  // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}
-  // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}
-  // CHECK-Darwin: {{    #2 0x.* in malloc.*}}
-  // CHECK-Darwin: {{    #3 0x.* in _?main .*heap-overflow.cc:21}}
+  // CHECK-Darwin: {{    #0 0x.* in wrap_malloc.*}}
+  // CHECK-Darwin: {{    #1 0x.* in _?main .*heap-overflow.cc:21}}
----------------
_?wrap_malloc here and below?

================
Comment at: tests/CMakeLists.txt:84
@@ -83,3 +83,3 @@
                  LINK_FLAGS "-framework Foundation")
-    target_link_libraries(${testname} clang_rt.asan_osx)
+    target_link_libraries(${testname} clang_rt.asan_osx_dynamic)
   elseif (ANDROID)
----------------
Will static runtime work at all after this change? If no, plan to remove rules for building it in /lib/asan/CMakeLists.txt


http://llvm-reviews.chandlerc.com/D216



More information about the llvm-commits mailing list