[llvm-commits] [compiler-rt] r162834 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_common.h sanitizer_printf.cc sanitizer_stacktrace.cc

Alexey Samsonov samsonov at google.com
Wed Aug 29 04:12:17 PDT 2012


On Wed, Aug 29, 2012 at 12:54 PM, Kostya Serebryany <kcc at google.com> wrote:

>
>
> On Wed, Aug 29, 2012 at 12:50 PM, Dmitry Vyukov <dvyukov at google.com>wrote:
>
>> On Wed, Aug 29, 2012 at 12:40 PM, Kostya Serebryany <kcc at google.com>wrote:
>>
>>> Author: kcc
>>> Date: Wed Aug 29 03:40:36 2012
>>> New Revision: 162834
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=162834&view=rev
>>> Log:
>>> [asan/tsan] use InternalScopedBuffer instead of stack arrays. Use mmap
>>> inseted of InternalAlloc in InternalScopedBuffer
>>>
>>> Modified:
>>>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
>>>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>>>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
>>>
>>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=162834&r1=162833&r2=162834&view=diff
>>>
>>> ==============================================================================
>>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
>>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Wed Aug 29
>>> 03:40:36 2012
>>> @@ -55,15 +55,17 @@
>>>
>>>  // InternalScopedBuffer can be used instead of large stack arrays to
>>>  // keep frame size low.
>>> +// FIXME: use InternalAlloc instead of MmapOrDie once
>>> +// InternalAlloc is made libc-free.
>>>  template<typename T>
>>>  class InternalScopedBuffer {
>>>   public:
>>>    explicit InternalScopedBuffer(uptr cnt) {
>>>      cnt_ = cnt;
>>> -    ptr_ = (T*)InternalAlloc(cnt * sizeof(T));
>>> +    ptr_ = (T*)MmapOrDie(cnt * sizeof(T), "InternalScopedBuffer");
>>>
>>
>>
>> Please make it using malloc again. It was always intended to be
>> "scoped-malloc" and extensively used in tsan.
>>
>
Note that we've encountered the problem on Android where __libc_malloc is
still calling our interceptors for malloc.
AFAIR this behavior would crash TSan (if we ever decide to port it).

>
> We can not use libc malloc in asan and should not use it in tsan either.
> So, we either need to have two variants of InternalScopedBuffer, or we
> need to fix InternalAlloca to not depend on libc.
> The former is simpler, the latter is better.
> Thoughts?
>

This depends on how "good" and efficient our InternalAlloc should be (that
is, how difficult would it be to implement
yet another allocator, gr-r-r). For code in sanitizer_common/ we're
probably not that interested in efficiency. Can't tell for tsan.

-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120829/66358b9e/attachment.html>


More information about the llvm-commits mailing list