Describe the bug
I have been using Tauri on a new project for a few months. However, I have noticed that Tauri can crash from time to time. I decided to try to narrow down the possible causes.
Here is a basic program (only the file lib.rs was modified after running pnpm create tauri-app) that can crash on both Windows and Linux, within 1s to 60s:
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.setup(|app| {
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
loop {
let _handle = app_handle.clone();
let func_a = |app_handle: AppHandle| {
for _ in 0..1000 {
let _ = app_handle.available_monitors();
}
};
let func_b = |app_handle: AppHandle| {
for _ in 0..1000 {
let _ = app_handle.cursor_position();
}
};
let mut handles = vec!();
for _ in 0..10 {
let a_handle = app_handle.clone();
let b_handle = app_handle.clone();
handles.push(std::thread::spawn(move || {func_a(a_handle)}));
handles.push(std::thread::spawn(move || {func_b(b_handle)}));
}
for (_i, h) in handles.into_iter().enumerate() {
let _ = h.join();
}
}
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Basically, the functions available_monitors and cursor_position are not thread safe. There might be other problematic functions, but I have only tested those. The crashes are more frequent when func_a and func_b are called, but can occur with only func_a or func_b.
Thanks in advance.
Reproduction
The error can occur both in debug or release mode. Here is an example:
pnpm install
pnpm tauri build --debug --no-bundle
./src-tauri/target/debug/crashtauri
Here is the project (without node_modules or release folders):
crashtauri.zip
Expected behavior
The functions called from app.handle should not cause the program to crash.
Full tauri info output
[✔] Environment
- OS: Linux Mint 22.2.0 x86_64 (X64) (cinnamon on x11)
✔ webkit2gtk-4.1: 2.48.7
✔ rsvg2: 2.58.0
✔ rustc: 1.90.0 (1159e78c4 2025-09-14)
✔ cargo: 1.90.0 (840b83a10 2025-07-30)
✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
- node: 22.21.1
- pnpm: 10.20.0
- npm: 10.9.4
[-] Packages
- tauri 🦀: 2.10.3
- tauri-build 🦀: 2.5.6
- wry 🦀: 0.54.4, (outdated, latest: 0.55.0)
- tao 🦀: 0.34.8, (outdated, latest: 0.35.0)
- @tauri-apps/api ⱼₛ: 2.10.1
- @tauri-apps/cli ⱼₛ: 2.10.1
[-] Plugins
- tauri-plugin-opener 🦀: 2.5.3
- @tauri-apps/plugin-opener ⱼₛ: 2.5.3
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: React
- bundler: Vite
Stack trace
Multiple errors can occur. For examples:
Aborted (core dumped)
or
Segmentation fault (core dumped)
or
malloc(): unaligned fastbin chunk detected
Aborted (core dumped)
Additional context
No response
Describe the bug
I have been using Tauri on a new project for a few months. However, I have noticed that Tauri can crash from time to time. I decided to try to narrow down the possible causes.
Here is a basic program (only the file lib.rs was modified after running
pnpm create tauri-app) that can crash on both Windows and Linux, within 1s to 60s:Basically, the functions available_monitors and cursor_position are not thread safe. There might be other problematic functions, but I have only tested those. The crashes are more frequent when
func_aandfunc_bare called, but can occur with onlyfunc_aorfunc_b.Thanks in advance.
Reproduction
The error can occur both in debug or release mode. Here is an example:
pnpm installpnpm tauri build --debug --no-bundle./src-tauri/target/debug/crashtauriHere is the project (without node_modules or release folders):
crashtauri.zip
Expected behavior
The functions called from app.handle should not cause the program to crash.
Full
tauri infooutputStack trace
Additional context
No response