Skip to content

Pin creack/pty past the lost-TIOCGPTN bug to fix a flaky pane start - #54

Merged
Amitgb14 merged 1 commit into
masterfrom
conch/fix-creator-flake
Oct 18, 2026
Merged

Amitgb14 merged 1 commit into
masterfrom
conch/fix-creator-flake

Conversation

@Amitgb14

Copy link
Copy Markdown
Owner

TestCreatorEveryWayFromAfar failed in CI now and then with fork/exec …: operation not permitted.

Cause. creack/pty v1.1.20–v1.1.24 turns the pointer for TIOCGPTN into a uintptr before the call that makes the system call. A GC that shrinks the goroutine's stack in between has the kernel write the pty's number into the old stack. Open then reads 0, opens /dev/pts/0 (another pane's terminal), and TIOCSCTTY fails with EPERM.

Fix. The upstream fix (creack/pty#215) is merged but not released, so go.mod pins the master pseudo-version, with a comment saying why. go mod tidy also moves pkg/sftp to a direct requirement.

Test. TestPtyOpenNamesItsOwnTerminal (Linux only) opens ptys under GC pressure and checks that each tty belongs to its own master.

  • On v1.1.24 it failed on every run: 1–2 wrong in about 100 opens.
  • On the pinned version it found 0 wrong in about 110k opens over 5 runs.
  • I checked both by cross-compiling and running on a Linux host.

go test -race -count=1 ./..., go vet ./... and gofmt -l cmd internal pass on macOS.

🤖 Generated with Claude Code

TestCreatorEveryWayFromAfar failed in CI now and then with "fork/exec …:
operation not permitted". creack/pty v1.1.20–v1.1.24 turned the pointer
for TIOCGPTN into a uintptr before the call making the system call, so a
GC shrinking the goroutine's stack in between had the kernel write the
pty's number into the old stack: Open read 0, opened /dev/pts/0 — another
pane's terminal — and TIOCSCTTY failed with EPERM.

The fix (creack/pty#215) is merged upstream but unreleased, so go.mod pins
the master pseudo-version. TestPtyOpenNamesItsOwnTerminal (Linux) opens
ptys under GC pressure and checks each tty is the master's own: on
v1.1.24 it fails within a run, on the pinned version 0 wrong in ~110k
opens.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Amitgb14
Amitgb14 merged commit d9341ab into master Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant