[PATCH] Optional support for dynamic Asan runtime

Yury Gribov tetra2005 at gmail.com
Wed Mar 26 12:24:24 PDT 2014



================
Comment at: lib/asan/asan_malloc_linux.cc:115
@@ +114,3 @@
+  if (!asan_inited)
+    return AsanPreinitAlloc(size);
+  if (AsanIsPreinitAllocated(ptr))
----------------
Alexey Samsonov wrote:
> Yury Gribov wrote:
> > Alexey Samsonov wrote:
> > > This is just wrong. Is realloc() called before asan_inited or on PreinitAllocated pointers?
> > AFAIR realloc() is called before asan_inited on PreinitAlloc-ated pointers (dlerror calls it to allocate string). So what's wrong exactly?
> if realloc(ptr, new_size) != ptr, you have to copy the contents to the newly allocated buffer. It's so sad we need to appease dlerror() with hacks like this. Can you clarify why you need to call it in AsanCheckIncompatibleRT?
> you have to copy the contents

Agreed, won't work in general case. Was enough for dlerror because I was ignoring them anyway.

> Can you clarify why you need to call it in AsanCheckIncompatibleRT?

I search for __asan_static via dlsym() and this fails and calls dlerror().

> It's so sad we need to appease dlerror() with hacks like this

It is. Unfortunately this seems to be the only reliable way to detect incompatible rts (which is super-important).

================
Comment at: test/asan/TestCases/Linux/interception_malloc_test.cc:13
@@ +12,3 @@
+extern "C"
+__attribute__((no_sanitize_address))  // Malloc may be called from dlsym in __asan_init
+void *malloc(size_t size) {
----------------
Alexey Samsonov wrote:
> So, how does __attribute__((no_sanitize_address)) help here?
I think malloc's frame gets poisoned which caused segfault because shadow is not initialized (malloc is called at the beginning of asan_init in dlsym).


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



More information about the llvm-commits mailing list