[PATCH] Optional support for dynamic Asan runtime
tetra2005 at gmail.com
Thu Mar 27 08:16:40 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:
> > > 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).
> Can you search for ASan runtime (.so) in the contents of /proc/self/maps when initializing a static runtime? I think we can read it w/o calling malloc...
> Or to add asan_runtime_type .bss global, and initialize it in __asan_init(). Set it to 1 if ASAN_DYNAMIC is set, and to 2 otherwise, and detect inconsistencies.
> Can you search for ASan runtime (.so) in the contents of /proc/self/maps
No, this won't protect from dlopening dynamic rt.
> Or to add asan_runtime_type .bss global
Yup, this might work. I'll see how it goes tomorrow.
More information about the llvm-commits