Hi,

I've found a regression in ncurses 6.6 (patchdate 20251230) where
setupterm() fails on valid Linux pseudo-terminals, causing tmux's
tty_init() to fail and "open terminal failed: not a terminal" on attach.

The issue does NOT occur with ncurses 6.5 (patchdate 20240427) or
the Ubuntu system ncurses 6.4.


ENVIRONMENT

  OS:       Ubuntu 24.04.4 LTS
  Kernel:   6.8.0-107-generic x86_64
  tmux:     3.6b (Homebrew)
  ncurses:  6.6.20251230 (Homebrew, wide-char build)
            6.5.20240427 (built from source, same configure flags)
            6.4+20240113 (Ubuntu system /lib/x86_64-linux-gnu)


REPRODUCTION

  # Using tmux 3.6b linked against ncurses 6.6:
  $ tmux new -d -s test
  $ tmux attach -t test
  open terminal failed: not a terminal

  This happens in:
  - Interactive SSH sessions (ssh user@host, then tmux a)
  - VS Code Remote integrated terminal
  - PTYs created by script(1)

  The ONLY working case is ssh -t host "tmux a -t test" (forced PTY
  with terminal size forwarding from the SSH client).


ISOLATION

  Same tmux 3.6b binary, different ncurses library at runtime:

  | ncurses           | method                              | result  |
  |-------------------|-------------------------------------|---------|
  | 6.6.20251230      | default brew linkage                | FAIL    |
  | 6.5.20240427      | LD_LIBRARY_PATH=.../ncurses-6.5/lib | OK      |
  | 6.4 (system)      | LD_LIBRARY_PATH=/lib/x86_64-linux-gnu | OK    |

  Commands to reproduce the isolation test:

    # FAIL with 6.6
    script -qc 'tmux -S /tmp/t66 new -d -s x && \
                 tmux -S /tmp/t66 a -t x' /dev/null

    # OK with 6.5
    script -qc 'LD_LIBRARY_PATH=/path/to/ncurses-6.5/lib \
                 tmux -S /tmp/t65 new -d -s x && \
                 LD_LIBRARY_PATH=/path/to/ncurses-6.5/lib \
                 tmux -S /tmp/t65 a -t x' /dev/null


MECHANISM

  tmux's server receives the client's PTY fd via SCM_RIGHTS, then
  calls tty_init() -> setupterm(). With ncurses 6.6, setupterm()
  apparently rejects the terminal, causing tty_init() to return -1.
  This leaves the CLIENT_TERMINAL flag unset, and server_client_open()
  returns "not a terminal".

  strace shows the PTY is valid — TCGETS succeeds, the fd resolves
  to /dev/pts/N, and permissions are correct (crw--w---- owner:tty).
  The tmux source code for this path is identical between 3.4 and
  3.6b, confirming the behavioral change is in ncurses, not tmux.


BUILD FLAGS (both 6.5 and 6.6 built with):

  ./configure --prefix=... --with-shared --with-widec \
    --enable-pc-files --enable-sigwinch --enable-ext-colors \
    --without-debug --without-ada


I haven't bisected the exact ncurses patch between 6.5 and 6.6 yet.
Happy to test patches or provide additional traces if helpful.

Thanks,
Liam

Reply via email to