Options for controlling block poisoning intervals, validation checks, and deprecation warnings.
Macros | |
#define | PW_ALLOCATOR_BLOCK_POISON_INTERVAL 0 |
#define | PW_ALLOCATOR_HARDENING_BASIC 1 |
#define | PW_ALLOCATOR_HARDENING_ROBUST 2 |
#define | PW_ALLOCATOR_HARDENING_DEBUG 3 |
#define | PW_ALLOCATOR_HARDENING PW_ALLOCATOR_HARDENING_ROBUST |
#define | PW_ALLOCATOR_SUPPRESS_DEPRECATED_WARNINGS 1 |
#define | PW_ALLOCATOR_DEPRECATED |
#define PW_ALLOCATOR_BLOCK_POISON_INTERVAL 0 |
Controls how frequently blocks are poisoned on deallocation.
Blocks may be "poisoned" when deallocated by writing a pattern to their useable memory space. When next allocated, the pattern is checked to ensure it is unmodified, i.e. that nothing has changed the memory while it was free. If the memory has been changed, then a heap-overflow, use-after-free, or other memory corruption bug exists and the program aborts.
If set to 0, poisoning is disabled. For any other value N, every Nth block is poisoned. This allows consumers to stochiastically sample allocations for memory corruptions while mitigating the performance impact.
#define PW_ALLOCATOR_HARDENING PW_ALLOCATOR_HARDENING_ROBUST |
Enables validation checks.
Possible values are:
See those values for a description of the types of checks associated with each level. Subsequent levels include the former, i.e. 'debug' includes 'robust', which includes 'basic'. Additional checks can detect more errors at the cost of performance and code size.
#define PW_ALLOCATOR_HARDENING_BASIC 1 |
Applies essential checks only.
This is a possible value for PW_ALLOCATOR_HARDENING
.
Essential checks include those that should almost never be disabled. An example is input validation on the public API, e.g. checking if a pointer passed to Allocator::Deallocate
]refers to valid allocation.
#define PW_ALLOCATOR_HARDENING_DEBUG 3 |
Applies all checks.
This is a possible value for PW_ALLOCATOR_HARDENING
.
Debug checks include those that check invariants whose failure indicates a defect in pw_allocator itself. For example, allocating a new block from an existing valid free block should result in both blocks being valid with consistent sizes and pointers to neighbors.
See PW_ALLOCATOR_HARDENING_BASIC
for a description of essential checks. See PW_ALLOCATOR_HARDENING_ROBUST
for a description of recommended checks.
#define PW_ALLOCATOR_HARDENING_ROBUST 2 |
Applies recommended and essential checks.
This is a possible value for PW_ALLOCATOR_HARDENING
.
Recommended checks include those that can detect memory corruption. These can be very useful in uncovering software defects in other components and in preventing some security vulnerabilities. As a result, disabling these checks is discouraged for all projects except those that have strict size requirements and very high confidence in their codebase.
See PW_ALLOCATOR_HARDENING_BASIC
for a description of essential checks.
#define PW_ALLOCATOR_SUPPRESS_DEPRECATED_WARNINGS 1 |
Suppresses warnings about using legacy allocator interfaces.
This module is undergoing refactoring to improve flexibility and performance. Some portions of the API that are being updated are in use by downstream consumers. These legacy interfaces are preserved for now, but deprecated.
Initially, this setting defaults to 1 and these interfaces may still be consumed without warning. At some point, this will default to 0. Downstream projects may still suppress the warning by overriding this configuration, but must be aware that legacy interfaces will eventually be removed.
See b/376730645 for background and details.