tauri-apps/tauri · error
unable to create thread with 8MiB stack
Error message
unable to create thread with 8MiB stack
What it means
Thrown at build time from generated code: the Tauri context is built inside a dedicated thread with an 8 MiB stack (to survive deep recursive macro/codegen structures), and `std::thread::Builder::spawn` failing triggers this panic. Spawn failure means the OS refused to create the thread — resource exhaustion (threads/memory), RLIMIT constraints, or running on a platform that disallows the requested stack size.
Solutions
- Free memory / close processes on the machine and retry the build or run.
- Raise the thread/process limit (`ulimit -u unlimited`) or container memory limits.
- Check RLIMIT constraints in the sandbox and permit pthread creation with the requested stack size.
- Retry on a normal host/CI runner with adequate resources.
Example fix
# before: thread limit hit ulimit -u 64 # after ulimit -u 4096 cargo tauri dev
Defensive patterns
Strategy: validation
Validate before calling
# before building in constrained environments, check thread limits and memory ulimit -u ulimit -v # ensure generous limits, e.g.: ulimit -u 4096 free -m # ensure hundreds of MB free
Prevention
- Raise ulimit -u and container memory limits on build machines
- Watch available memory in CI before running tauri builds
- Avoid seccomp profiles that block pthread_create
- Retry on a standard host if the sandbox restricts thread creation
When it happens
Trigger: Compiling/running a Tauri app where the generated context code spawns the 8MiB-stack thread and the OS denies thread creation: hitting thread/memory ulimits, out of memory, or restricted sandbox denying pthread_create.
Common situations: Memory-constrained containers/CI; hitting `ulimit -u` (max threads/processes); heavily restricted seccomp/AppArmor sandboxes; extremely low RLIMIT_STACK configurations.
Related errors
- embedded file asset has no parent
- failed to get random bytes
- failed to parse capabilities
- failed to parse plugin manifest map
- failed to read capabilities
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/b1e1747a44a4b87f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri-codegen/src/context.rs:481
);
#with_tray_icon_code
#maybe_config_parent_setter
context
});
// Wrapping in a function to make rust analyzer faster,
// see https://github.com/tauri-apps/tauri/pull/14457
// We take the assets as an argument so when the caller provides custom `assets` the closure
// does not capture from the caller's scope ("can't capture dynamic environment in a fn item").
let output = quote!({
fn inner<R: #root::Runtime, A: #root::Assets<R> + 'static>(assets: A) -> #root::Context<R> {
let thread = ::std::thread::Builder::new()
.name(String::from("generated tauri context creation"))
.stack_size(8 * 1024 * 1024)
.spawn(move || #context)
.expect("unable to create thread with 8MiB stack");
match thread.join() {
Ok(context) => context,
Err(_) => {
eprintln!("the generated Tauri `Context` panicked during creation");
::std::process::exit(101);
}
}
}
inner(#assets)
});
Ok(output)
}
fn find_icon(
config: &Config,
config_parent: &Path,View on GitHub (pinned to 460ec35447)