ci: replace global RUST_TEST_THREADS=1 with per-crate --test-threads=1#280
Merged
Brooooooklyn merged 5 commits intomainfrom Mar 21, 2026
Merged
ci: replace global RUST_TEST_THREADS=1 with per-crate --test-threads=1#280Brooooooklyn merged 5 commits intomainfrom
Brooooooklyn merged 5 commits intomainfrom
Conversation
e990dd9 to
9bf941d
Compare
Brooooooklyn
approved these changes
Mar 20, 2026
Member
Merge activity
|
On musl, fork() is unsafe when other threads exist — even threads sleeping on a futex leave musl internal state that the child inherits in an inconsistent form, causing SIGSEGV between fork and exec. A process-wide mutex (PTY_LOCK) cannot fix this because the test harness still spawns multiple threads (one per test). The real fix is --test-threads=1 for PTY test binaries, which ensures only one thread exists during fork. Split `cargo test` into: - Non-PTY tests: run in parallel (default thread count) - PTY tests (pty_terminal, pty_terminal_test, vite_task_bin): run with --test-threads=1 This removes the global RUST_TEST_THREADS=1 that forced ALL tests to run sequentially, improving CI speed for non-PTY tests. https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8
On musl libc, fork() in a multi-threaded process is unsafe because musl internal state (locks, allocator metadata) in other threads can be left inconsistent in the child, causing SIGSEGV/SIGBUS. portable_pty uses pre_exec() for PTY setup, which forces Rust's Command to use fork()+exec() instead of posix_spawn(). This commit bypasses portable_pty's spawn_command() on musl and uses posix_spawn() directly, which musl implements via clone(CLONE_VM|CLONE_VFORK) — avoiding fork() entirely. PTY setup is handled via spawn attributes and file actions: - POSIX_SPAWN_SETSID for session leadership (replaces setsid()) - addopen() on the slave TTY path sets the controlling terminal - SETSIGDEF/SETSIGMASK for signal cleanup (replaces manual signal reset) This allows all tests (including PTY tests) to run in parallel on musl, removing the need for per-crate --test-threads=1. https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8
…lel tests" This reverts commit 4dd37ba.
On musl libc, fork() in a multi-threaded process is unsafe because musl internal state (locks, allocator metadata) in other threads can be left inconsistent in the child, causing SIGSEGV/SIGBUS. cargo-nextest runs each test in its own process (not thread), so fork() happens from a mostly single-threaded context. Tests still execute in parallel across processes, maintaining fast CI times without SIGSEGV. This replaces the per-crate --test-threads=1 workaround which serialized all tests within each crate. https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8
…o test cargo-nextest can't discover tests in packages with `harness = false` (e2e_snapshots, plan_snapshots) because they output custom formats instead of the standard libtest listing. Split the musl test run: - nextest for standard-harness tests (parallel, per-process isolation) - cargo test for custom-harness packages (already run sequentially) https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8
15e7473 to
c0a3c55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RUST_TEST_THREADS=1from the musl CI jobcargo testinto non-PTY tests (parallel) and PTY tests (--test-threads=1)Details
On musl,
fork()is unsafe when other threads exist — even threads sleeping on a futex leave musl internal state that the child inherits in an inconsistent form, causing SIGSEGV between fork and exec.A process-wide mutex (
PTY_LOCK) cannot fix this because the test harness still spawns multiple threads. The real fix is--test-threads=1for PTY test binaries only (pty_terminal,pty_terminal_test,vite_task_bin), ensuring a single thread exists during fork.Test plan
https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8