Skip to content

term: clamp zero window size from Docker PTY#959

Open
tomholford wants to merge 1 commit intourbit:developfrom
tomholford:th/i/159/fix-docker-tty-zero-winsize
Open

term: clamp zero window size from Docker PTY#959
tomholford wants to merge 1 commit intourbit:developfrom
tomholford:th/i/159/fix-docker-tty-zero-winsize

Conversation

@tomholford
Copy link
Contributor

@tomholford tomholford commented Feb 6, 2026

Summary

  • When Docker allocates a PTY (tty: true + stdin_open: true) but nobody is attached, TIOCGWINSZ succeeds but reports 0x0
  • This causes unsigned underflow in row_l - 1 calculations throughout term.c and a decrement-underflow crash in drum when it receives %blew [0 0]
  • Clamp to 80x24 defaults when ioctl returns zero dimensions (matching existing fallback when ioctl fails)
  • Fix initial default row_l from 0 to 24

Resolves #159.

Test plan

  • Build with zig build
  • Cross-compile with zig build -Dtarget=aarch64-linux-musl -Doptimize=ReleaseFast
  • Run in Docker with tty: true + stdin_open: true and no docker attach — ship boots without crashing
  • Verify docker attach / detach still works after boot

Reproduction steps

# Cross-compile for Linux
zig build -Dtarget=aarch64-linux-musl -Doptimize=ReleaseFast

# Build Docker image
cp zig-out/aarch64-linux-musl/urbit docker/
docker build -t vere-test docker/

# Create volume with comet file
docker volume create test-comet
docker run --rm -v test-comet:/urbit alpine touch /urbit/test-ship.comet

# Run with tty + stdin_open, no attach (previously crashed)
docker run -d --name test-vere -t -i -v test-comet:/urbit vere-test

# Verify ship boots
docker logs -f test-vere

# Cleanup
docker stop test-vere && docker rm test-vere
docker volume rm test-comet

When Docker allocates a PTY (tty: true + stdin_open: true) but nobody
is attached, TIOCGWINSZ succeeds but reports 0x0. This causes unsigned
underflow in row_l - 1 calculations throughout term.c and a
decrement-underflow crash in Arvo's drum when it receives %blew [0 0].

Clamp to 80x24 defaults when ioctl returns zero dimensions, matching
the existing fallback when ioctl fails. Also fix the initial default
row_l from 0 to 24 to match col_l.

Resolves urbit#159.
@tomholford tomholford marked this pull request as ready for review February 8, 2026 01:40
@tomholford tomholford requested a review from a team as a code owner February 8, 2026 01:40
@Fang- Fang- self-requested a review February 9, 2026 16:29
Copy link
Collaborator

@Fang- Fang- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of where the dimensions come from, zeroes in %blew are bogus, so clamping like this is good. Arguably 0 == col_l instead of !col_l would be semantically clearer, but it's C, so readers know.

@pkova
Copy link
Collaborator

pkova commented Feb 9, 2026

What version of vere are you running when you blow up with your reproduction commands? We've been unable to reproduce on linux-x86_64 and linux-aarch64.

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.

Docker: tloncorp/vere bails during launch

3 participants