aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorii14 <ii14@users.noreply.github.com>2023-04-22 03:27:32 +0200
committerii14 <ii14@users.noreply.github.com>2023-05-15 16:50:58 +0200
commit4cc69f45b4a56c1c0f0ac8ac15b66dffe00d4615 (patch)
tree802b847c0a63499c63141fefabcea0e3eb59092a
parent33687f5e87a0f048f7bc02d4658e58ef8cc0fd49 (diff)
downloadrneovim-4cc69f45b4a56c1c0f0ac8ac15b66dffe00d4615.tar.gz
rneovim-4cc69f45b4a56c1c0f0ac8ac15b66dffe00d4615.tar.bz2
rneovim-4cc69f45b4a56c1c0f0ac8ac15b66dffe00d4615.zip
build: add ubsan default options
Use print_stacktrace=1 for UBSAN by default.
-rw-r--r--CONTRIBUTING.md2
-rwxr-xr-xcontrib/asan.sh3
-rw-r--r--contrib/flake.nix1
-rw-r--r--src/nvim/CMakeLists.txt1
-rw-r--r--src/nvim/README.md3
-rw-r--r--src/nvim/main.c14
6 files changed, 17 insertions, 7 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 85dc0fdbfd..4c8387fbd2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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.
diff --git a/contrib/asan.sh b/contrib/asan.sh
index baf7abb5a8..6354d65514 100755
--- a/contrib/asan.sh
+++ b/contrib/asan.sh
@@ -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
diff --git a/contrib/flake.nix b/contrib/flake.nix
index d38d1fd2b7..59d977b748 100644
--- a/contrib/flake.nix
+++ b/contrib/flake.nix
@@ -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
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 325b376b30..070cea3b59 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -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
diff --git a/src/nvim/README.md b/src/nvim/README.md
index cbd5daba4e..75155fb9c6 100644
--- a/src/nvim/README.md
+++ b/src/nvim/README.md
@@ -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"
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 659eccc6f0..4999d9dd2a 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -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