mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibSantizer: Read $UBSAN_OPTIONS to set deadliness on first print
The first time we want to print a UBSAN violation, the UBSAN runtime in userspace will get the UBSAN_OPTIONS environment variable to check if it contains the string "halt_on_error=1". This is clearly not robust to invalid options or adding more options, but it gets the job done at the moment. :^)
This commit is contained in:
parent
97444f0a25
commit
882002c566
Notes:
sideshowbarker
2024-07-18 11:22:02 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/882002c5669 Pull-request: https://github.com/SerenityOS/serenity/pull/8285 Reviewed-by: https://github.com/alimpfard
1 changed files with 10 additions and 1 deletions
|
@ -10,7 +10,7 @@
|
|||
using namespace AK::UBSanitizer;
|
||||
|
||||
// FIXME: Parse option from UBSAN_OPTIONS: halt_on_error=0 or 1
|
||||
bool AK::UBSanitizer::g_ubsan_is_deadly { false }; // FIXME: Make true!!
|
||||
bool AK::UBSanitizer::g_ubsan_is_deadly { false };
|
||||
|
||||
#define WARNLN_AND_DBGLN(fmt, ...) \
|
||||
warnln(fmt, ##__VA_ARGS__); \
|
||||
|
@ -28,6 +28,15 @@ static void print_location(const SourceLocation& location)
|
|||
// FIXME: Dump backtrace of this process (with symbols? without symbols?) in case the user wants non-deadly UBSAN
|
||||
// Should probably go through the kernel for SC_dump_backtrace, then access the loader's symbol tables rather than
|
||||
// going through the symbolizer service?
|
||||
|
||||
static bool checked_env_for_deadly = false;
|
||||
if (!checked_env_for_deadly) {
|
||||
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 (g_ubsan_is_deadly) {
|
||||
WARNLN_AND_DBGLN("UB is configured to be deadly");
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Reference in a new issue