[GWP-ASan] Allow late initialisation if single-threaded.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 3 Feb 2020 20:25:51 +0000 (12:25 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 3 Feb 2020 20:34:26 +0000 (12:34 -0800)
commit0d6fccb460e515a78c33dcd97cda459332ddd63a
treea072ef083ef00d1c4e374c0e1dbaf4e0ce0c8081
parent2758ae41aece0c9d1df759fade3f3abf40baf515
[GWP-ASan] Allow late initialisation if single-threaded.

Summary:
This patch allows for late initialisation of the GWP-ASan allocator. Previously, if late initialisation occurred, the sample counter was never updated, meaning we would end up having to wait for 2^32 allocations before getting a sampled allocation.

Now, we initialise the sampling mechanism in init() as well. We require init() to be called single-threaded, so this isn't a problem.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: merge_guards_bot, mgorny, #sanitizers, llvm-commits, cferris

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D73896
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
compiler-rt/lib/gwp_asan/tests/late_init.cpp [new file with mode: 0644]