Much better now https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitizer_allocator.cc File lib/sanitizer_common/sanitizer_allocator.cc (right): https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitizer_allocator.cc#newcode59 lib/sanitizer_common/sanitizer_allocator.cc:59: if (atomic_compare_exchange_strong(&internal_allocator_initialized, this must be either ...
11 years, 9 months ago
(2013-04-30 06:55:57 UTC)
#1
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitizer_allocator.cc File lib/sanitizer_common/sanitizer_allocator.cc (right): https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitizer_allocator.cc#newcode59 lib/sanitizer_common/sanitizer_allocator.cc:59: if (atomic_compare_exchange_strong(&internal_allocator_initialized, On 2013/04/30 06:55:57, dvyukov wrote: > this ...
11 years, 9 months ago
(2013-05-06 07:08:45 UTC)
#2
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
File lib/sanitizer_common/sanitizer_allocator.cc (right):
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
lib/sanitizer_common/sanitizer_allocator.cc:59: if
(atomic_compare_exchange_strong(&internal_allocator_initialized,
On 2013/04/30 06:55:57, dvyukov wrote:
> this must be either double-checked locking or better explicitly initialize it
in
> tool's Init(). hopefully it does not have any dependencies.
> have you tried explicit init?
Do you mean the following?
if (!internal_allocator_initialized) {
if (atomic_compare_exchane...()) {
internal_allocator_instance->Init();
}
}
In case of explicit Init() we must make sure that we call it early enough so
that
internal allocator is not used before it. This is doable, but adds an opaque
dependency. Also, UBSan doesn't have explicit __ubsan_init(), and it uses code
from sanitizer_common.
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
File lib/sanitizer_common/sanitizer_allocator_internal.h (right):
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
lib/sanitizer_common/sanitizer_allocator_internal.h:35: static const uptr
kInternalAllocatorSpace = 0x690000000000ULL;
On 2013/04/30 06:55:57, dvyukov wrote:
> is it used in asan?
> this won't work on windows
ASan doesn't work on 64-bit Windows anyway.
11 years, 9 months ago
(2013-05-06 15:18:18 UTC)
#3
On 2013/05/06 07:08:45, samsonov wrote:
>
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
> File lib/sanitizer_common/sanitizer_allocator.cc (right):
>
>
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
> lib/sanitizer_common/sanitizer_allocator.cc:59: if
> (atomic_compare_exchange_strong(&internal_allocator_initialized,
> On 2013/04/30 06:55:57, dvyukov wrote:
> > this must be either double-checked locking or better explicitly initialize
it
> in
> > tool's Init(). hopefully it does not have any dependencies.
> > have you tried explicit init?
> Do you mean the following?
>
> if (!internal_allocator_initialized) {
> if (atomic_compare_exchane...()) {
> internal_allocator_instance->Init();
> }
> }
Yes, something like that, but using atomic_load(memory_order_acquire) for the
first check. And you can use a mutex to wait for initialization:
if (atomic_load(&inited, memory_order_acquire) == 0) {
Lock l(&mtx);
if (inited == 0) {
Init();
atomic_store(&inited, 1, memory_order_release);
}
}
> In case of explicit Init() we must make sure that we call it early enough so
> that
> internal allocator is not used before it. This is doable, but adds an opaque
> dependency.
Yes, but as the result we will understand how our tools work.
What do you mean by the "opaque dependency"?
> Also, UBSan doesn't have explicit __ubsan_init(), and it uses code
> from sanitizer_common.
It's not a good idea to spread lazy initialization over sanitizer common because
of that.
It's better to add ubsan_init(). You can use the lazy initialization there for
now.
>
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
> File lib/sanitizer_common/sanitizer_allocator_internal.h (right):
>
>
https://codereview.appspot.com/8666045/diff/2001/lib/sanitizer_common/sanitiz...
> lib/sanitizer_common/sanitizer_allocator_internal.h:35: static const uptr
> kInternalAllocatorSpace = 0x690000000000ULL;
> On 2013/04/30 06:55:57, dvyukov wrote:
> > is it used in asan?
> > this won't work on windows
>
> ASan doesn't work on 64-bit Windows anyway.
Issue 8666045: Switch InternalAlloc to use custom allocator instead of libc malloc
(Closed)
Created 11 years, 9 months ago by samsonov
Modified 11 years, 7 months ago
Reviewers: dvyukov
Base URL: https://llvm.org/svn/llvm-project/compiler-rt/trunk/
Comments: 6