tmux crashes on tpm init

Bug #1812387 reported by Prasanna Loganathar
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tmux-plugin-manager (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

[Impact]

Initializing the tpm plugin for tmux causes it to crash.

[Test Case]

Getting the core dump is sometimes tricky. This procedure generates it every time:

$ lxc launch ubuntu-daily:cosmic tester && lxc exec tester bash

# apt update && apt dist-upgrade -y && apt install -y tmux tmux-plugin-manager &&
ulimit -c unlimited &&
cat << 'EOF' >"$HOME/.tmux.conf"
# set prefix: Alt + e
set -g prefix M-e
# Let's bind this too, so that repeated
# presses work, esp. when nesting.
bind -n M-e send-prefix

# start window numbering at 1
set -g base-index 1
# start pane numbering at 1
set -g pane-base-index 1

# use mouse
set -g mouse on
setw -g mode-keys vi

# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

set -g @scroll-down-exit-copy-mode off
set -g @scroll-without-changing-pane on
set -g @emulate-scroll-for-no-mouse-alternate-buffer on

# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-logging'

run -b "/usr/share/tmux-plugin-manager/tpm"
EOF

# tmux

* Press alt-e, then shift-i
* exit immediately:

# exit
# tmux

* Press alt-e, then shift-i

Result:

root@tester:~# [lost server]
                            root@tester:~#

[Original Description]

Crash on a fresh install and first start after adding tmux plugin manager.

ProblemType: Crash
DistroRelease: Ubuntu 18.10
Package: tmux 2.7-1
ProcVersionSignature: Ubuntu 4.18.0-13.14-generic 4.18.17
Uname: Linux 4.18.0-13-generic x86_64
ApportVersion: 2.20.10-0ubuntu13.1
Architecture: amd64
CurrentDesktop: GNOME
Date: Fri Jan 18 19:09:19 2019
ExecutablePath: /usr/bin/tmux
ExecutableTimestamp: 1523656091
InstallationDate: Installed on 2019-01-01 (17 days ago)
InstallationMedia: Ubuntu 18.10 "Cosmic Cuttlefish" - Release amd64 (20181017.3)
ProcCmdline: tmux
ProcCwd: /home/pvl
Signal: 11
SourcePackage: tmux
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm cdrom dip docker libvirt lpadmin plugdev sambashare sudo
modified.conffile..etc.apport.crashdb.conf: [modified]
mtime.conffile..etc.apport.crashdb.conf: 2019-01-15T04:51:59.517661

Revision history for this message
Prasanna Loganathar (pvl) wrote :
Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 ?? ()
 evbuffer_add (buf=0x55fae21ee6f0, data_in=data_in@entry=0x55fae21d14c0, datlen=0) at buffer.c:1730
 cmdq_print (item=<optimized out>, fmt=fmt@entry=0x55fae1094589 "%s") at cmd-queue.c:421
 cmd_run_shell_print (msg=msg@entry=0x55fae21ca3b0 "", job=<optimized out>) at cmd-run-shell.c:68
 cmd_run_shell_callback (job=0x55fae21f1850) at cmd-run-shell.c:131

Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : StacktraceSource.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
Changed in tmux (Ubuntu):
importance: Undecided → Medium
tags: removed: need-amd64-retrace
Revision history for this message
Karl Stenerud (kstenerud) wrote : Re: tmux crash while installing tmux plugin manager

Hi Prasanna, thanks for the report!

I've been unable to replicate the issue in a test setup. I set things up as follows:

lxc launch ubuntu-daily:cosmic tester
lxc exec tester bash
apt update
apt dist-upgrade -y
apt install -y tmux-plugin-manager
tmux

Can you please check that nothing else is installed?

Also, please check upstream to see if anyone else has had crashes in evbuffer_add(). Even if you did have other things installed, it should never crash in such a function.

Changed in tmux (Ubuntu):
status: New → Incomplete
Revision history for this message
Prasanna Loganathar (pvl) wrote :

Hi Karl,

I've been able to reproduce it accurately, although the cause, now that I looked in a little closer is a little more intricate. Sometimes, the UI seems to recover behind the scenes hiding the crash, and sometimes it doesn't. Also ubuntu's default has a coredump limit set to 0, hiding the crashes even further.

I ran it as a full blown VM just so that I could duplicate the conditions of my initial crash more closely. (But it likely should work with lxc as well)

1. apt update && apt dist-upgrade -y && apt install tmux git
2. git clone https://github.com/tmux-plugins/tpm "$HOME/.config/tmux-plugins/tpm"
3. create tmux config

Here's my config (modified to reproduce this error):

```
# set prefix: Alt + e
set -g prefix M-e
# Let's bind this too, so that repeated
# presses work, esp. when nesting.
bind -n M-e send-prefix

# start window numbering at 1
set -g base-index 1
# start pane numbering at 1
set -g pane-base-index 1

# use mouse
set -g mouse on
setw -g mode-keys vi

# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

set -g @scroll-down-exit-copy-mode off
set -g @scroll-without-changing-pane on
set -g @emulate-scroll-for-no-mouse-alternate-buffer on

# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-logging'

## --------
## BUG-NOTE: This is the line that triggers the crash.
## While tpm is anyway set into .tmux/plugins/tpm, using that
## is probably the better config -- which works without the crash
## however, setting it to a different location like this, makes
## tmux crash
## --------
TPM_BIN='~/.config/tmux-plugins/tpm/tpm'
# && test -f "$TPM_DIR" && "$TPM_DIR"
run -b "test -f $TPM_BIN && $TPM_BIN || true"

```

4. Open tmux. Hit Alt+I (initializing tpm, that causes tmux to crash)
5. tree /var/crash -a
/var/crash/
├── .lock
└── _usr_bin_tmux.1000.crash

Revision history for this message
Prasanna Loganathar (pvl) wrote :

Note: You probably might want to set `ulimit -c unlimited` before any of the above to make the system generate the core dumps.

information type: Private → Public
summary: - tmux crash while installing tmux plugin manager
+ tmux crashes on tpm init
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Prasanna,
thank you for the detailed instructions.
I ran this on Bionic/Cosmic/Disco to get a feeling if tmux recently broke or got fixed.
That is matching versions:
 tmux | 2.6-3ubuntu0.1 | bionic-updates
 tmux | 2.7-1 | cosmic
 tmux | 2.8-2 | disco

I don't get a crash in any of those :-/

Since you set prefix to Alt+e to initialize the TPM it actually is "alt+e I".
And I see:
TMUX environment reloaded
Done, press ENTER to continue

No crashes nor anything similar.

To make sure the conf really is loaded I ran
  $ tmux source ~/.tmux.conf
But still nothing happened then or on another re-init.

I can get a list of installed plugins by entering the update function via
"Alt+e U"
So TPM did initialize properly.
I could update all plugins through that.

I switched from the git based TPM that you recommended to the actual one in the Ubuntu Archive and adapted the paths.
In the config you then end like:
  run -b '/usr/share/tmux-plugin-manager/tpm'

Still worked just fine.

Revision history for this message
Prasanna Loganathar (pvl) wrote :

Hi Christian,

Alright, did a little more digging. It looks like incomplete installation of tpm/tpm plugins, or some race condition with multiple tpm execution that's causing the crash. I put it as docker image for convenience.

How to reproduce the bug:

1. docker run -it --rm prasannavl/tmux-launchpad-bug-1812387
2. tmux
3. Alt + e + I
4. exit (Don't wait for tpm to finish)
5. tmux
6. Alt + e + I (again)

Wait for the tpm completion message, and visible tmux crash with [lost server] message on console.

Revision history for this message
Prasanna Loganathar (pvl) wrote :

Reference attachment: Dockerfile

Revision history for this message
Prasanna Loganathar (pvl) wrote :

Reference attachment: tmux.conf

Robie Basak (racb)
tags: added: server-triage-discuss
Revision history for this message
Karl Stenerud (kstenerud) wrote :

Hi Prasanna,

Do you have repro steps that don't involve fetching from github? We can only really work with setups that use ubuntu repositories, because there's no way to tell how software from outside is set up.

tags: removed: server-triage-discuss
Revision history for this message
Prasanna Loganathar (pvl) wrote :

I've updated the docker image prasannavl/tmux-launchpad-bug-1812387 to only use ubuntu-repo based tmux-plugin-manager.

It still crashes with "[lost-server]". Same steps as above should work.

**Dockerfile:**

```
FROM ubuntu:18.10

RUN apt update && apt dist-upgrade -y && \
apt install tmux tmux-plugin-manager git tree -y && \
ulimit -c unlimited

COPY tmux.conf "/root/.tmux.conf"
CMD bash
```

**tmux.conf:**

```
# set prefix: Alt + e
set -g prefix M-e
# Let's bind this too, so that repeated
# presses work, esp. when nesting.
bind -n M-e send-prefix

# start window numbering at 1
set -g base-index 1
# start pane numbering at 1
set -g pane-base-index 1

# use mouse
set -g mouse on
setw -g mode-keys vi

# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

set -g @scroll-down-exit-copy-mode off
set -g @scroll-without-changing-pane on
set -g @emulate-scroll-for-no-mouse-alternate-buffer on

# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-logging'

run -b "/usr/share/tmux-plugin-manager/tpm"

```

Revision history for this message
Prasanna Loganathar (pvl) wrote :

Reproduction steps again, for reference:

1. docker run -it --rm prasannavl/tmux-launchpad-bug-1812387
2. tmux
3. Alt + e + I
4. exit (Don't wait for tpm to finish)
5. tmux
6. Alt + e + I (again)

Wait for the tpm completion message, and visible tmux crash with [lost server] message on console.

Revision history for this message
Karl Stenerud (kstenerud) wrote :

Confirmed. LXD repro instructions:

$ lxc launch ubuntu-daily:cosmic tester && lxc exec tester bash

# apt update && apt dist-upgrade -y && apt install -y tmux tmux-plugin-manager &&
ulimit -c unlimited &&
cat << 'EOF' >"$HOME/.tmux.conf"
# set prefix: Alt + e
set -g prefix M-e
# Let's bind this too, so that repeated
# presses work, esp. when nesting.
bind -n M-e send-prefix

# start window numbering at 1
set -g base-index 1
# start pane numbering at 1
set -g pane-base-index 1

# use mouse
set -g mouse on
setw -g mode-keys vi

# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

set -g @scroll-down-exit-copy-mode off
set -g @scroll-without-changing-pane on
set -g @emulate-scroll-for-no-mouse-alternate-buffer on

# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-logging'

run -b "/usr/share/tmux-plugin-manager/tpm"
EOF

# tmux

* Press alt-e, then shift-i
* exit immediately:

# exit
# tmux

* Press alt-e, then shift-i

Result:

root@tester:~# [lost server]
                            root@tester:~#

Changed in tmux (Ubuntu):
status: Incomplete → Confirmed
description: updated
Robie Basak (racb)
tags: added: server-triage-discuss
Revision history for this message
Karl Stenerud (kstenerud) wrote :

Hi Prasanna,

I've checked on tmux-plugin-manager and as it is in universe, it isn't directly supported by Canonical. If you would like to investigate yourself and put in a fix, I can help guide you through the process.

tags: removed: server-triage-discuss
affects: tmux (Ubuntu) → tmux-plugin-manager (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.