LibSanitizer: Check for halt_on_error=0 in $UBSAN_OPTIONS

This allows a developer to set the g_ubsan_is_deadly flag to true by
default and still disable UBSAN for certain applications.
This commit is contained in:
Andrew Kaster 2021-11-22 22:56:09 -07:00 committed by Brian Gianforcaro
parent 815f15f82c
commit 3e9fb9f23c
Notes: sideshowbarker 2024-07-17 22:46:02 +09:00

View file

@ -9,7 +9,6 @@
using namespace AK::UBSanitizer;
// FIXME: Parse option from UBSAN_OPTIONS: halt_on_error=0 or 1
bool AK::UBSanitizer::g_ubsan_is_deadly { false };
#define WARNLN_AND_DBGLN(fmt, ...) \
@ -34,8 +33,12 @@ static void print_location(const SourceLocation& location)
checked_env_for_deadly = true;
StringView options = getenv("UBSAN_OPTIONS");
// FIXME: Parse more options and complain about invalid options
if (!options.is_null() && options.contains("halt_on_error=1"))
g_ubsan_is_deadly = true;
if (!options.is_null()) {
if (options.contains("halt_on_error=1"))
g_ubsan_is_deadly = true;
else if (options.contains("halt_on_error=0"))
g_ubsan_is_deadly = false;
}
}
if (g_ubsan_is_deadly) {
WARNLN_AND_DBGLN("UB is configured to be deadly");