build: add ubsan default options

Use print_stacktrace=1 for UBSAN by default.
This commit is contained in:
ii14 2023-04-22 03:27:32 +02:00
parent 33687f5e87
commit 4cc69f45b4
6 changed files with 17 additions and 7 deletions

View File

@ -187,7 +187,7 @@ master build. To view the defects, just request access; you will be approved.
```
- When running Neovim, use
```
UBSAN_OPTIONS=print_stacktrace=1 ASAN_OPTIONS=log_path=/tmp/nvim_asan,handle_abort=1,handle_sigill=1 nvim args...
ASAN_OPTIONS=log_path=/tmp/nvim_asan nvim args...
```
- If Neovim exits unexpectedly, check `/tmp/nvim_asan.{PID}` (or your preferred `log_path`) for log files with error messages.

View File

@ -13,9 +13,6 @@ export CC='clang'
# Change to detect_leaks=1 to detect memory leaks (slower).
export ASAN_OPTIONS="detect_leaks=0:log_path=$log_path/asan"
# Show backtraces in the logs.
export UBSAN_OPTIONS="print_stacktrace=1"
make -C "$root_path" CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim

View File

@ -106,7 +106,6 @@
# ASAN_OPTIONS=detect_leaks=1
export ASAN_OPTIONS="log_path=./test.log:abort_on_error=1"
export UBSAN_OPTIONS=print_stacktrace=1
# for treesitter functionaltests
mkdir -p runtime/parser

View File

@ -836,6 +836,7 @@ if(ENABLE_ASAN_UBSAN)
-fsanitize=address
-fsanitize=undefined)
target_link_libraries(nvim PRIVATE -fsanitize=address -fsanitize=undefined)
target_compile_definitions(nvim PRIVATE ENABLE_ASAN_UBSAN)
elseif(ENABLE_MSAN)
message(STATUS "Enabling memory sanitizer for nvim.")
target_compile_options(nvim PRIVATE

View File

@ -71,9 +71,8 @@ Create a directory to store logs:
Configure the sanitizer(s) via these environment variables:
# Change to detect_leaks=1 to detect memory leaks (slower, noisier).
export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan,handle_abort=1,handle_sigill=1"
export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan"
# Show backtraces in the logs.
export UBSAN_OPTIONS=print_stacktrace=1
export MSAN_OPTIONS="log_path=${HOME}/logs/msan"
export TSAN_OPTIONS="log_path=${HOME}/logs/tsan"

View File

@ -2222,3 +2222,17 @@ static void check_swap_exists_action(void)
}
handle_swap_exists(NULL);
}
#ifdef ENABLE_ASAN_UBSAN
const char *__ubsan_default_options(void);
const char *__ubsan_default_options(void)
{
return "print_stacktrace=1";
}
const char *__asan_default_options(void);
const char *__asan_default_options(void)
{
return "handle_abort=1,handle_sigill=1";
}
#endif