13using namespace MaxOS::runtime;
16UBSanHandler::UBSanHandler() =
default;
18UBSanHandler::~UBSanHandler() =
default;
28 ASSERT(
false,
"UBSAN ERROR AT %s:%d:%d - %s", location.
file, location.
line, location.
column, msg);
42 msg =
"misaligned memory access";
61 msg =
"misaligned memory access";
Creates a string using a using a combination of parts with the '<<' operator. Simmilar to the logger.
static void handle(source_location_t location, const char *msg)
Handles the UBSan error (currently only printing the location and panicking)
static void print_type_mismatch(type_mismatch_info_t *info, uintptr_t ptr)
Prints the type mismatch error for UBSan.
static void print_type_mismatch_v1(type_mismatch_info_v1_t *info, uintptr_t ptr)
Prints the type mismatch error for UBSan v1.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
#define ASSERT(condition, format,...)
If the specified condition is not met then the kernel will crash with the specified message.
Information about an invalid value error.
source_location_t location
The location of the invalid value.
Information that an error that only has a location.
source_location_t location
The location of the error.
Information about an out of bounds error.
source_location_t location
The location of the out of bounds access.
Information about an overflow error.
source_location_t location
The location of the overflow.
Information about a shift out of bounds error.
source_location_t location
The location of the shift out of bounds.
The location in the source code where the undefined behaviour occurred.
uint32_t line
The line number in the source file.
uint32_t column
The column number in the source file.
const char * file
The name of the source file.
char name[]
The name of the type.
Information about a type mismatch error (version 1)
source_location_t location
The location of the type mismatch.
unsigned char log_alignment
The log2 of the required alignment.
unsigned char type_check_kind
The kind of type check that failed.
type_descriptor_t * type
The type that was expected.
Information about a type mismatch error.
source_location_t location
The location of the type mismatch.
uint8_t type_check_kind
The kind of type check that failed.
uintptr_t alignment
The required alignment.
type_descriptor_t * type
The type that was expected.
Information about a VLA bound not positive error.
source_location_t location
The location of the VLA bound not positive.
void __ubsan_handle_divrem_overflow(overflow_info_t *info)
Triggered when dividing or taking the remainder results in an overflow (eg dividing INT_MIN by -1)
void __ubsan_handle_out_of_bounds(out_of_bounds_info_t *info)
Triggered when accessing an array at an index larger than its size (or negative)
void __ubsan_handle_builtin_unreachable(location_only_info_t *info)
Triggered when reaching code that should be unreachable.
void __ubsan_handle_mul_overflow(overflow_info_t *info)
Triggered when multiplying beyond the maximum value for the type.
void __ubsan_handle_sub_overflow(overflow_info_t *info)
Triggered when subtracting below the minimum value for the type.
void __ubsan_handle_vla_bound_not_positive(vla_bound_not_positive_info_t *info)
Triggered when a variable length array (VLA) is declared with a non-positive bound.
void __ubsan_handle_type_mismatch_v1(type_mismatch_info_v1_t *info, uintptr_t ptr)
Triggered when memory is accessed with an unexpected type (UBSan v1 - includes more metadata)
void __ubsan_handle_pointer_overflow(overflow_info_t *info)
Triggered when adding/subbing to a memory address is outside the expected bounds.
void __ubsan_handle_shift_out_of_bounds(shift_out_of_bounds_info_t *info)
Triggered when shifting beyond the capacity of the type.
void __ubsan_handle_load_invalid_value(invalid_value_info_t *info)
Triggered when loading a value that is invalid for its type (eg corrupted or uninitialised)
void __ubsan_handle_add_overflow(overflow_info_t *info)
Triggered when adding beyond the maximum value for the type.
void __ubsan_handle_missing_return(location_only_info_t *info)
Triggered when a function that is expected to return a value does not.
void __ubsan_handle_type_mismatch(type_mismatch_info_t *info, uintptr_t ptr)
Triggered when memory is accessed with an unexpected type.
void __ubsan_handle_negate_overflow(overflow_info_t *info)
Triggered when negating (taking -x) when there is no corresponding positive/negative value.
Defines structures and a handler for Undefined Behavior Sanitizer (UBSan) runtime errors.
#define ubsan_aligned(value, alignment)
Check if a value is aligned to the given alignment.
const char * TYPE_CHECK_KINDS[]
List of type check errors.