mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-10 19:34:29 +00:00
[Sanitizers] Make sanitizer allocator linker-initialize compliant.
Summary: These four SpinMutex ctors was the only code executed in the ctor for the static __asan::Allocator instance (same for the other sanitizers allocators), which is supposed to be fully linker-initialized. Also, when the global ctor for this allocator instance is executed, this instance might already be initialized by __asan_init called from .preinit_array. Issue: https://github.com/google/sanitizers/issues/194 Reviewers: morehouse, eugenis, cryptoad Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D48142 llvm-svn: 334660
This commit is contained in:
parent
a00c372cd3
commit
3fc66075c7
@ -314,6 +314,6 @@ class LargeMmapAllocator {
|
||||
struct Stats {
|
||||
uptr n_allocs, n_frees, currently_allocated, max_allocated, by_size_log[64];
|
||||
} stats;
|
||||
SpinMutex mutex_;
|
||||
StaticSpinMutex mutex_;
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ class AllocatorGlobalStats : public AllocatorStats {
|
||||
}
|
||||
|
||||
private:
|
||||
mutable SpinMutex mu_;
|
||||
mutable StaticSpinMutex mu_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -90,6 +90,9 @@ class Quarantine {
|
||||
atomic_store_relaxed(&max_size_, size);
|
||||
atomic_store_relaxed(&min_size_, size / 10 * 9); // 90% of max size.
|
||||
atomic_store_relaxed(&max_cache_size_, cache_size);
|
||||
|
||||
cache_mutex_.Init();
|
||||
recycle_mutex_.Init();
|
||||
}
|
||||
|
||||
uptr GetSize() const { return atomic_load_relaxed(&max_size_); }
|
||||
@ -142,8 +145,8 @@ class Quarantine {
|
||||
atomic_uintptr_t min_size_;
|
||||
atomic_uintptr_t max_cache_size_;
|
||||
char pad1_[kCacheLineSize];
|
||||
SpinMutex cache_mutex_;
|
||||
SpinMutex recycle_mutex_;
|
||||
StaticSpinMutex cache_mutex_;
|
||||
StaticSpinMutex recycle_mutex_;
|
||||
Cache cache_;
|
||||
char pad2_[kCacheLineSize];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user