Skip to content

Commit 05f9323

Browse files
committed
fix: serialize milestone tests on musl to prevent SIGSEGV
The PTY_LOCK in pty_terminal serializes spawn and FD cleanup, but interleaved reads/writes between two live Terminals can still trigger SIGSEGV in musl internals. Add a test-level mutex so milestone tests (which maintain long-lived interactive PTY sessions) don't overlap.
1 parent bd7aee9 commit 05f9323

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/pty_terminal_test/tests/milestone.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
use std::io::Write;
2+
#[cfg(target_env = "musl")]
3+
use std::sync::Mutex;
24

35
use ntest::timeout;
46
use portable_pty::CommandBuilder;
57
use pty_terminal::geo::ScreenSize;
68
use pty_terminal_test::TestTerminal;
79
use subprocess_test::command_for_fn;
810

11+
// On musl, concurrent PTY spawns + FD operations in the same process cause
12+
// SIGSEGV in musl internals. The crate-level PTY_LOCK serializes spawn and
13+
// drop, but interleaved reads/writes between two live Terminals can still
14+
// trigger the race. Serialize entire test bodies as a workaround.
15+
#[cfg(target_env = "musl")]
16+
static TEST_MUTEX: Mutex<()> = Mutex::new(());
17+
918
#[test]
1019
#[timeout(5000)]
1120
fn milestone_raw_mode_keystrokes() {
21+
#[cfg(target_env = "musl")]
22+
let _guard = TEST_MUTEX.lock().unwrap_or_else(|e| e.into_inner());
23+
1224
let cmd = CommandBuilder::from(command_for_fn!((), |(): ()| {
1325
use std::io::{Read, Write, stdout};
1426

@@ -77,6 +89,9 @@ fn milestone_raw_mode_keystrokes() {
7789
#[test]
7890
#[timeout(5000)]
7991
fn milestone_does_not_pollute_screen() {
92+
#[cfg(target_env = "musl")]
93+
let _guard = TEST_MUTEX.lock().unwrap_or_else(|e| e.into_inner());
94+
8095
let cmd = CommandBuilder::from(command_for_fn!((), |(): ()| {
8196
use std::io::{Read, Write, stdout};
8297

0 commit comments

Comments
 (0)