From b62fa0675372b9b52b78c6dc8f2aee8c7985eac0 Mon Sep 17 00:00:00 2001 From: Daniel Rainer Date: Wed, 21 Jan 2026 18:59:32 +0100 Subject: [PATCH] asan: remove redundant handling The special exit handling when running with address sanitization no longer seems necessary. Our tests all pass without it. Similarly, the leak sanitizer suppression is no longer needed, since we don't get any warnings when running our checks without it. Because our Rust code no longer has any ASAN-specific behavior, we don't need the `asan` feature anymore. Closes #12366 --- Cargo.toml | 1 - build_tools/lsan_suppressions.txt | 3 --- cmake/Rust.cmake | 1 - src/panic.rs | 3 +-- src/threads/threads.rs | 12 ------------ 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a8055c746..da77631cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -185,7 +185,6 @@ localize-messages = ["dep:fish-gettext"] gettext-extract = ["dep:fish-gettext-extraction"] # The following features are auto-detected by the build-script and should not be enabled manually. -asan = [] tsan = [] [workspace.lints] diff --git a/build_tools/lsan_suppressions.txt b/build_tools/lsan_suppressions.txt index 4b1ffd56e..e69de29bb 100644 --- a/build_tools/lsan_suppressions.txt +++ b/build_tools/lsan_suppressions.txt @@ -1,3 +0,0 @@ -# LSAN can detect leaks tracing back to __asan::AsanThread::ThreadStart (probably caused by our -# threads not exiting before their TLS dtors are called). Just ignore it. -leak:AsanThread diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 521da0c03..0be10db9c 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -6,7 +6,6 @@ set(FISH_RUST_BUILD_DIR "${CMAKE_BINARY_DIR}/cargo") if(DEFINED ASAN) list(APPEND CARGO_FLAGS "-Z" "build-std") - list(APPEND FISH_CARGO_FEATURES_LIST "asan") endif() if(DEFINED TSAN) list(APPEND CARGO_FLAGS "-Z" "build-std") diff --git a/src/panic.rs b/src/panic.rs index b7b7423f8..8cd05e011 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -12,7 +12,7 @@ use crate::{ common::{get_program_name, read_blocked}, nix::isatty, - threads::{asan_maybe_exit, is_main_thread}, + threads::is_main_thread, }; pub static AT_EXIT: OnceLock> = OnceLock::new(); @@ -59,6 +59,5 @@ pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! { if let Some(at_exit) = AT_EXIT.get() { (at_exit)(); } - asan_maybe_exit(exit_status); std::process::exit(exit_status) } diff --git a/src/threads/threads.rs b/src/threads/threads.rs index eca17bcf7..3c6509458 100644 --- a/src/threads/threads.rs +++ b/src/threads/threads.rs @@ -178,18 +178,6 @@ pub fn spawn(callback: F) -> bool { result } -/// Exits calling onexit handlers if running under ASAN, otherwise does nothing. -/// -/// This function is always defined but is a no-op if not running under ASAN. This is to make it -/// more ergonomic to call it in general and also makes it possible to call it via ffi at all. -pub fn asan_maybe_exit(code: i32) { - if cfg!(feature = "asan") { - unsafe { - libc::exit(code); - } - } -} - /// Data shared between the thread pool [`ThreadPool`] and worker threads [`WorkerThread`]. #[derive(Default)] struct ThreadPoolProtected {