Attaching from a zero-size terminal panics
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
Start with the reproduction script in the issue, run it against a local build, and read the panic sites: screen.rs:897 (Screen::text) and grid.rs:200 (Screen::el) in the vendored shpool_vt100 crate. The attach path is spawn_shell_to_client and handle_attach in libshpool's daemon shell module, which is where the zero-size resize is passed to the parser. Done means a 0x0 attach or create no longer kills the shell-to-client thread, and later attaches succeed in all three session_restore_mode cases.
Written by the indexing model from the issue text.
Description
AI Policy Ack
ACK
This bug report is written manually.
However, I used an AI agent to investigate the issue and create a reproduction script.
What happened
- My bash startup attaches to
shpoolfrom every interactive bash, potentially reusing disconnected sessions. - Since May, my terminals regularly couldn't attach.
- My suspicion was that this was somehow related to VSCode's WSL connections.
- I also saw
resized fd (rows=0, cols=0)entries just before panics that tried to unwrap aNonevalue atshpool_vt100-0.1.3/src/screen.rs:897. - My daemon logged this 67 times between May and October.
- It happens with
session_restore_modeset to{ lines = 1000 }(mine) or"screen", but not with"simple".
What I expected to happen
- The attach should either work or be refused before creating a session.
To Reproduce
Here is an agent-created script that reproduces the issue by either creating a new session from a zero-size terminal (case A) or reattaching from a zero-size terminal (case B)
#!/usr/bin/env bash
# Reproduces a shpool panic: an attach from a terminal of size 0x0 kills
# the session's shell->client thread, and the session can never be
# attached again. Case A creates a new session at 0x0; case B reattaches
# a disconnected one at 0x0. Runs its own daemon on its own socket in a
# temporary directory, so no running shpool is touched. Needs util-linux's
# `script`.
#
# usage: SHPOOL=/path/to/shpool shpool-zero-size.sh [lines|screen|simple]
set -u
shpool=${SHPOOL:-shpool}
mode=${1:-lines}
dir=$(mktemp -d)
sock=$dir/shpool.socket
log=$dir/daemon.log
case $mode in
lines) restore='session_restore_mode = { lines = 1000 }' ;;
screen) restore='session_restore_mode = "screen"' ;;
simple) restore='session_restore_mode = "simple"' ;;
*) echo "unknown mode $mode" >&2; exit 2 ;;
esac
cat >"$dir/config.toml" <<EOF
shell = "/bin/sh"
norc = true
prompt_prefix = ""
$restore
EOF
attach="$shpool -c $dir/config.toml -s $sock attach"
# Attach $2 from a terminal of size $1, for at most 3 seconds; exit 124
# means it was still attached when timeout ended it, as it should be.
try() {
script -qec "stty $1; timeout 3 $attach $2" /dev/null >/dev/null
echo "$?"
}
status() { "$shpool" -s "$sock" list | grep "^$1"; }
echo "shpool: $("$shpool" version), session_restore_mode: $mode"
RUST_BACKTRACE=1 "$shpool" -c "$dir/config.toml" -s "$sock" -l "$log" daemon 2>"$dir/daemon.stderr" &
daemon=$!
trap 'kill "$daemon" 2>/dev/null; wait "$daemon" 2>/dev/null' EXIT
for _ in $(seq 50); do [[ -S $sock ]] && break; sleep 0.1; done
echo "A. a new session from a 0x0 terminal"
echo " create at 0x0 exited $(try 'rows 0 cols 0' fresh)"
sleep 2
echo " attach at 24x80 exited $(try 'rows 24 cols 80' fresh)"
echo " attach -f at 24x80 exited $(try 'rows 24 cols 80' '-f fresh')"
echo " list: $(status fresh)"
echo "B. a disconnected session reattached from a 0x0 terminal"
echo " create at 24x80 exited $(try 'rows 24 cols 80' old)"
for _ in $(seq 50); do status old | grep -q disconnected && break; sleep 0.1; done
echo " reattach at 0x0 exited $(try 'rows 0 cols 0' old)"
sleep 2
echo " reattach at 24x80 exited $(try 'rows 24 cols 80' old)"
echo " reattach -f at 24x80 exited $(try 'rows 24 cols 80' '-f old')"
echo " list: $(status old)"
echo "--- daemon stderr, the panics:"
grep -a -E "panicked at|^ +[0-9]+: " "$dir/daemon.stderr"
echo "--- daemon log, the attaches after them:"
grep -a -E "clobbering|joining shell->client on reattach|error shuffling" "$log" | sed 's/^[^ ]* *//'
echo "(full log: $log)"
Output:
shpool: shpool 0.11.0, session_restore_mode: lines
A. a new session from a 0x0 terminal
create at 0x0 exited 1
attach at 24x80 exited 124
attach -f at 24x80 exited 1
list: fresh disconnected
B. a disconnected session reattached from a 0x0 terminal
create at 24x80 exited 124
reattach at 0x0 exited 1
reattach at 24x80 exited 124
reattach -f at 24x80 exited 1
list: old disconnected
--- daemon stderr, the panics:
thread 'shell->client(fresh)' (665098) panicked at /build/shpool-0.11.0-vendor/source-registry-0/shpool_vt100-0.1.3/src/screen.rs:897:18:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic
3: core::option::unwrap_failed
4: <shpool_vt100::screen::Screen>::text
5: <shpool_vt100::parser::Parser>::process
6: <libshpool::daemon::shell::SessionInner>::spawn_shell_to_client::{closure#0}
thread 'shell->client(old)' (665178) panicked at /build/shpool-0.11.0-vendor/source-registry-0/shpool_vt100-0.1.3/src/grid.rs:200:14:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic
3: core::option::unwrap_failed
4: <shpool_vt100::screen::Screen>::el
5: <vte::Parser<1024>>::action_csi_dispatch::<shpool_vt100::perform::WrappedScreen>
6: <shpool_vt100::parser::Parser>::process
7: <libshpool::daemon::shell::SessionInner>::spawn_shell_to_client::{closure#0}
--- daemon log, the attaches after them:
WARN ThreadId(17) handle_conn{cid=6}:handle_attach:select_shell_lock_1(shells):aquired_lock(session.inner){s="fresh"}: child_exited chan unclosed, but shell->client thread has exited, clobbering with new subshell
ERROR ThreadId(17) handling new connection: joining shell->client on reattach: Any { .. }
ERROR ThreadId(20) handle_conn{cid=9}:handle_attach: error shuffling bytes: attaching new client stream to shell->client thread
WARN ThreadId(47) handle_conn{cid=28}:handle_attach:select_shell_lock_1(shells):aquired_lock(session.inner){s="old"}: child_exited chan unclosed, but shell->client thread has exited, clobbering with new subshell
ERROR ThreadId(47) handling new connection: joining shell->client on reattach: Any { .. }
ERROR ThreadId(50) handle_conn{cid=31}:handle_attach: error shuffling bytes: attaching new client stream to shell->client thread
(full log: /tmp/tmp.xI41MzDEcq/daemon.log)
Version info
shpool 0.11.0
Logs
Full logs for the reproduction script: daemon.log
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 70
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from shell-pool/shpool
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
shell-pool/shpool#463 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
shell-pool/shpool#442 · 1 comment ·
Maintainers usually reply within 1 day
-
misc LLM reportsOpen
Difficulty 5/5 Over a week Newbie friendliness 5/100
shell-pool/shpool#454 ·
Maintainers usually reply within 1 day
-
publish .deb filesOpen
Difficulty 4/5 3-5 days Newbie friendliness 55/100
shell-pool/shpool#429 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
shell-pool/shpool#412 · 2 comments ·
Maintainers usually reply within 1 day
All issues in shell-pool/shpool
Similar issues
-
Ignore entry for RUSTSEC-2026-0002 no longer matches anything (`lru` is no longer in `Cargo.lock`)Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
influxdata/influxdb#27767 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
oras-project/rust-oci-client-node#132 ·
Maintainers usually reply within 2 days
-
Ignore entry for RUSTSEC-2020-0168 no longer matches anything (`mach` is no longer in `Cargo.lock`)Possibly taken @zyl71 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Blockstream/lwk#213 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
libracoder/kiri#749 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manuscript-lang/manuscript#6389 ·
Maintainers usually reply within 1 day