tmux leaks memory in pane-border-status

Bug #1766942 reported by antgel on 2018-04-25
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tmux (Ubuntu)
Undecided
Unassigned
Bionic
Undecided
Karl Stenerud

Bug Description

[Impact]

A memory leak in tmux causes it to eventually fail when run for long periods of time. Since long term tmux sessions are common, this becomes a real problem for sysadmins, etc.

[Test Case]

# apt update
# apt dist-upgrade -y
# apt install -y tmux
# tmux -L none -f /dev/null new-session -s leaky-tmux-test 'tmux set-option -w -g pane-border-status top; tmux pipe-pane "cat>/tmp/leaky-tmux-test.log"; p=${TMUX#*,}; p=${p%,*}; s=0; j=0; echo "ITER: RSZ"; while [ $j -lt 6000 ] ; do j=$((j+1)); n=$(ps hwo rsz $p); printf "\e]2;%d: %d\e\\\\\r%4d: %d" $j $n $j $n; [ $s -ne $n ] && { echo; s=$n; }; done'
[exited]
# cat /tmp/leaky-tmux-test.log ; echo
ITER: RSZ
   1: 3712
1360: 3776
2725: 3904
4215: 4032
5743: 4160
6000: 4160 (example output)

RSZ will only change during the test if there's a memory leak. By comparison, we get correct behavior running without pane-border-status top:

$ tmux -L none -f /dev/null new-session -s leaky-tmux-test 'tmux pipe-pane "cat>/tmp/leaky-tmux-test.log"; p=${TMUX#*,}; p=${p%,*}; s=0; j=0; echo "ITER: RSZ"; while [ $j -lt 6000 ] ; do j=$((j+1)); n=$(ps hwo rsz $p); printf "\e]2;%d: %d\e\\\\\r%4d: %d" $j $n $j $n; [ $s -ne $n ] && { echo; s=$n; }; done'
[exited]
$ cat /tmp/leaky-tmux-test.log ; echo
ITER: RSZ
   1: 3492
6000: 3492

[Regression Potential]

Since this is only plugging a memory leak, no other behavior should be affected.

[Original Description]

The upstream bug is reported and fixed at https://github.com/tmux/tmux/issues/1167.

Can we either patch the package (patch at https://github.com/tmux/tmux/commit/c363c236aaea5b7a879493d8f3c85bead546f063) or upgrade to 2.7 (I guess this is less likely to happen given the imminent release).

Related branches

Changed in tmux (Ubuntu):
status: New → Fix Released
tags: added: server-next

Hi antgel,
I'm passing a few bugs with not enough attention atm.
Your report is great - I put it in a queue to hopefully be picked up soon.

Do you have a testcase other than waiting to see the issue?
It is in screen_redraw_make_pane_status so maybe there is something that forces the redraw one could loop on?

I tried
  $ while /bin/true; do tmux refresh-client; done
but that did not expose the issue.

Changed in tmux (Ubuntu Bionic):
status: New → Confirmed
Karl Stenerud (kstenerud) wrote :

Confirmed the behavior with the following test from https://github.com/tmux/tmux/issues/1167#issuecomment-349040998

Run a simple/crude test in order to verify this finding:

$ tmux -L none -f /dev/null new-session -s leaky-tmux-test 'tmux set-option -w -g pane-border-status top; tmux pipe-pane "cat>/tmp/leaky-tmux-test.log"; p=${TMUX#*,}; p=${p%,*}; s=0; j=0; echo "ITER: RSZ"; while [ $j -lt 6000 ] ; do j=$((j+1)); n=$(ps hwo rsz $p); printf "\e]2;%d: %d\e\\\\\r%4d: %d" $j $n $j $n; [ $s -ne $n ] && { echo; s=$n; }; done'
[exited]
$ cat /tmp/leaky-tmux-test.log ; echo
ITER: RSZ
   1: 3512
1993: 3568
3650: 3696
5279: 3824
6000: 3824

To compare, run it without tmux set-option -w -g pane-border-status top:

$ tmux -L none -f /dev/null new-session -s leaky-tmux-test 'tmux pipe-pane "cat>/tmp/leaky-tmux-test.log"; p=${TMUX#*,}; p=${p%,*}; s=0; j=0; echo "ITER: RSZ"; while [ $j -lt 6000 ] ; do j=$((j+1)); n=$(ps hwo rsz $p); printf "\e]2;%d: %d\e\\\\\r%4d: %d" $j $n $j $n; [ $s -ne $n ] && { echo; s=$n; }; done'
[exited]
$ cat /tmp/leaky-tmux-test.log ; echo
ITER: RSZ
   1: 3492
6000: 3492

-------------

Tested this with tmux 2.7 (in cosmic) and verified it fixed. Bionic is still affected.

Changed in tmux (Ubuntu Bionic):
assignee: nobody → Karl Stenerud (kstenerud)
Changed in tmux (Ubuntu Bionic):
status: Confirmed → In Progress
description: updated

Hello antgel, or anyone else affected,

Accepted tmux into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/tmux/2.6-3ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in tmux (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Łukasz Zemczak (sil2100) wrote :

Which package version has been used for verification? Please note that this information is required (as seen in #3 ).

Changed in tmux (Ubuntu Bionic):
status: Fix Committed → Incomplete
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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