diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-11-27 13:22:21 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-11-27 13:22:21 +0000 |
commit | e0e31c4a309148c6b513bae7e9db89a5963ce208 (patch) | |
tree | 9f958e901229984a93fd2d5cabc2f44c25254fec /compiler-rt | |
parent | b76b6876283ddfcb7da746434404d4b58cbe0f6d (diff) | |
download | bcm5719-llvm-e0e31c4a309148c6b513bae7e9db89a5963ce208.tar.gz bcm5719-llvm-e0e31c4a309148c6b513bae7e9db89a5963ce208.zip |
[ASan] Clarify that AsanThread objects are allocated only via mmap(). No functionality change.
llvm-svn: 195840
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.h | 10 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_stats.h | 4 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread.cc | 1 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread.h | 15 |
4 files changed, 13 insertions, 17 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h index c5fcbbb5d64..e366bc47fe6 100644 --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -91,16 +91,12 @@ class AsanChunkFifoList: public IntrusiveList<AsanChunk> { }; struct AsanThreadLocalMallocStorage { - explicit AsanThreadLocalMallocStorage(LinkerInitialized x) - { } - AsanThreadLocalMallocStorage() { - CHECK(REAL(memset)); - REAL(memset)(this, 0, sizeof(AsanThreadLocalMallocStorage)); - } - uptr quarantine_cache[16]; uptr allocator2_cache[96 * (512 * 8 + 16)]; // Opaque. void CommitBack(); + private: + // These objects are allocated via mmap() and are zero-initialized. + AsanThreadLocalMallocStorage() {} }; void *asan_memalign(uptr alignment, uptr size, StackTrace *stack, diff --git a/compiler-rt/lib/asan/asan_stats.h b/compiler-rt/lib/asan/asan_stats.h index e3030e88fdc..c66848dc571 100644 --- a/compiler-rt/lib/asan/asan_stats.h +++ b/compiler-rt/lib/asan/asan_stats.h @@ -47,9 +47,9 @@ struct AsanStats { uptr malloc_large; uptr malloc_small_slow; - // Ctor for global AsanStats (accumulated stats and main thread stats). + // Ctor for global AsanStats (accumulated stats for dead threads). explicit AsanStats(LinkerInitialized) { } - // Default ctor for thread-local stats. + // Creates empty stats. AsanStats(); void Print(); // Prints formatted stats to stderr. diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc index 328ac2fcd39..77156ebe737 100644 --- a/compiler-rt/lib/asan/asan_thread.cc +++ b/compiler-rt/lib/asan/asan_thread.cc @@ -81,7 +81,6 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, AsanThread *thread = (AsanThread*)MmapOrDie(size, __FUNCTION__); thread->start_routine_ = start_routine; thread->arg_ = arg; - thread->context_ = 0; return thread; } diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h index 11771ecd09f..3e612b2c722 100644 --- a/compiler-rt/lib/asan/asan_thread.h +++ b/compiler-rt/lib/asan/asan_thread.h @@ -101,14 +101,15 @@ class AsanThread { // True is this thread is currently unwinding stack (i.e. collecting a stack // trace). Used to prevent deadlocks on platforms where libc unwinder calls // malloc internally. See PR17116 for more details. - bool isUnwinding() const { return unwinding; } - void setUnwinding(bool b) { unwinding = b; } + bool isUnwinding() const { return unwinding_; } + void setUnwinding(bool b) { unwinding_ = b; } AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; } AsanStats &stats() { return stats_; } private: - AsanThread() : unwinding(false) {} + // NOTE: There is no AsanThread constructor. It is allocated + // via mmap() and *must* be valid in zero-initialized state. void SetThreadStackAndTls(); void ClearShadowForThreadStackAndTLS(); FakeStack *AsyncSignalSafeLazyInitFakeStack(); @@ -116,18 +117,18 @@ class AsanThread { AsanThreadContext *context_; thread_callback_t start_routine_; void *arg_; - uptr stack_top_; - uptr stack_bottom_; + uptr stack_top_; + uptr stack_bottom_; // stack_size_ == stack_top_ - stack_bottom_; // It needs to be set in a async-signal-safe manner. - uptr stack_size_; + uptr stack_size_; uptr tls_begin_; uptr tls_end_; FakeStack *fake_stack_; AsanThreadLocalMallocStorage malloc_storage_; AsanStats stats_; - bool unwinding; + bool unwinding_; }; // ScopedUnwinding is a scope for stacktracing member of a context |