mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
build: add ubsan default options
Use print_stacktrace=1 for UBSAN by default.
This commit is contained in:
parent
33687f5e87
commit
4cc69f45b4
@ -187,7 +187,7 @@ master build. To view the defects, just request access; you will be approved.
|
|||||||
```
|
```
|
||||||
- When running Neovim, use
|
- 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.
|
- If Neovim exits unexpectedly, check `/tmp/nvim_asan.{PID}` (or your preferred `log_path`) for log files with error messages.
|
||||||
|
|
||||||
|
@ -13,9 +13,6 @@ export CC='clang'
|
|||||||
# Change to detect_leaks=1 to detect memory leaks (slower).
|
# Change to detect_leaks=1 to detect memory leaks (slower).
|
||||||
export ASAN_OPTIONS="detect_leaks=0:log_path=$log_path/asan"
|
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"
|
make -C "$root_path" CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
|
||||||
VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim
|
VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@
|
|||||||
|
|
||||||
# ASAN_OPTIONS=detect_leaks=1
|
# ASAN_OPTIONS=detect_leaks=1
|
||||||
export ASAN_OPTIONS="log_path=./test.log:abort_on_error=1"
|
export ASAN_OPTIONS="log_path=./test.log:abort_on_error=1"
|
||||||
export UBSAN_OPTIONS=print_stacktrace=1
|
|
||||||
|
|
||||||
# for treesitter functionaltests
|
# for treesitter functionaltests
|
||||||
mkdir -p runtime/parser
|
mkdir -p runtime/parser
|
||||||
|
@ -836,6 +836,7 @@ if(ENABLE_ASAN_UBSAN)
|
|||||||
-fsanitize=address
|
-fsanitize=address
|
||||||
-fsanitize=undefined)
|
-fsanitize=undefined)
|
||||||
target_link_libraries(nvim PRIVATE -fsanitize=address -fsanitize=undefined)
|
target_link_libraries(nvim PRIVATE -fsanitize=address -fsanitize=undefined)
|
||||||
|
target_compile_definitions(nvim PRIVATE ENABLE_ASAN_UBSAN)
|
||||||
elseif(ENABLE_MSAN)
|
elseif(ENABLE_MSAN)
|
||||||
message(STATUS "Enabling memory sanitizer for nvim.")
|
message(STATUS "Enabling memory sanitizer for nvim.")
|
||||||
target_compile_options(nvim PRIVATE
|
target_compile_options(nvim PRIVATE
|
||||||
|
@ -71,9 +71,8 @@ Create a directory to store logs:
|
|||||||
Configure the sanitizer(s) via these environment variables:
|
Configure the sanitizer(s) via these environment variables:
|
||||||
|
|
||||||
# Change to detect_leaks=1 to detect memory leaks (slower, noisier).
|
# 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.
|
# Show backtraces in the logs.
|
||||||
export UBSAN_OPTIONS=print_stacktrace=1
|
|
||||||
export MSAN_OPTIONS="log_path=${HOME}/logs/msan"
|
export MSAN_OPTIONS="log_path=${HOME}/logs/msan"
|
||||||
export TSAN_OPTIONS="log_path=${HOME}/logs/tsan"
|
export TSAN_OPTIONS="log_path=${HOME}/logs/tsan"
|
||||||
|
|
||||||
|
@ -2222,3 +2222,17 @@ static void check_swap_exists_action(void)
|
|||||||
}
|
}
|
||||||
handle_swap_exists(NULL);
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user