class GuardedPoolAllocator
Defined at line 41 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
Functions in the public interface of this class are thread-compatible until
init() is called, at which point they become thread-safe (unless specified
otherwise).
Public Members
static const char *const kGwpAsanMetadataName
Public Methods
void GuardedPoolAllocator ()
During program startup, we must ensure that memory allocations do not land
in this allocation pool if the allocator decides to runtime-disable
GWP-ASan. The constructor value-initialises the class such that if no
further initialisation takes place, calls to shouldSample() and
pointerIsMine() will return false.
Defined at line 51 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
void GuardedPoolAllocator (const GuardedPoolAllocator & )
Defined at line 52 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
void init (const options::Options & Opts)
Initialise the rest of the members of this class. Create the allocation
pool using the provided options. See options.inc for runtime configuration
options.
GuardedPoolAllocator & operator= (const GuardedPoolAllocator & )
Defined at line 53 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
void uninitTestOnly ()
void disable ()
Functions exported for libmemunreachable's use on Android. disable()
installs a lock in the allocator that prevents any thread from being able
to allocate memory, until enable() is called.
void enable ()
void iterate (void * Base, size_t Size, iterate_callback Cb, void * Arg)
Execute the callback Cb for every allocation the lies in [Base, Base +
Size). Must be called while the allocator is disabled. The callback can not
allocate.
void * allocate (size_t Size, size_t Alignment)
Allocate memory in a guarded slot, with the specified `Alignment`. Returns
nullptr if the pool is empty, if the alignnment is not a power of two, or
if the size/alignment makes the allocation too large for this pool to
handle. By default, uses strong alignment (i.e. `max_align_t`), see
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2293.htm for discussion of
alignment issues in the standard.
void deallocate (void * Ptr)
Deallocate memory in a guarded slot. The provided pointer must have been
allocated using this pool. This will set the guarded slot as inaccessible.
size_t getSize (const void * Ptr)
Returns the size of the allocation at Ptr.
void ~GuardedPoolAllocator ()
Note: This class is expected to be a singleton for the lifetime of the
program. If this object is initialised, it will leak the guarded page pool
and metadata allocations during destruction. We can't clean up these areas
as this may cause a use-after-free on shutdown.
Defined at line 59 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
bool shouldSample ()
Return whether the allocation should be randomly chosen for sampling.
Defined at line 80 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
bool pointerIsMine (const void * Ptr)
Returns whether the provided pointer is a current sampled allocation that
is owned by this pool.
Defined at line 97 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
const AllocationMetadata * getMetadataRegion ()
Returns a pointer to the Metadata region, or nullptr if it doesn't exist.
Defined at line 117 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
const AllocatorState * getAllocatorState ()
Returns a pointer to the AllocatorState region.
Defined at line 120 of file ../../third_party/scudo/gwp_asan/guarded_pool_allocator.h
void preCrashReport (void * Ptr)
Functions that the signal handler is responsible for calling, while
providing the SEGV pointer, prior to dumping the crash, and after dumping
the crash (in recoverable mode only).
void postCrashReportRecoverableOnly (void * Ptr)
Protected Methods
size_t getRequiredBackingSize (size_t Size, size_t Alignment, size_t PageSize)
Returns the actual allocation size required to service an allocation with
the provided Size and Alignment.
uintptr_t alignUp (uintptr_t Ptr, size_t Alignment)
Returns the provided pointer that meets the specified alignment, depending
on whether it's left or right aligned.
uintptr_t alignDown (uintptr_t Ptr, size_t Alignment)