Memory leak in tmux pane title formatting

Bug #1835439 reported by Dan Watkins on 2019-07-04
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tmux (Ubuntu)
Undecided
Unassigned
Bionic
Undecided
Dan Watkins

Bug Description

[Impact]

When using powerline with tmux (on bionic), I am experiencing a memory leak that fills my VPS's 1GB of memory in a few days. To avoid memory exhaustion, I have to restart tmux (and therefore anything running in tmux).

[Test Case]

```
lxc launch ubuntu:b reproducer
lxc exec reproducer /bin/bash

# within container
apt update
apt install powerline
tmux

# within tmux
powerline-config tmux setup
```

Without the patch, I see resident set size (per ps) start at ~3MB and after ~30 minutes of tmux uptime it's up to ~4.5MB.

(With the patch, I see no increase in RSS over the same time period.)

[Regression Potential]

This patch affects the format expansion code path, which is used in multiple different ways in the tmux code base. These could all potentially be affected by this change.

Related branches

Dan Watkins (daniel-thewatkins) wrote :
Dan Watkins (daniel-thewatkins) wrote :

I have built a tmux package with an upstream patch[0] applied and this has addressed the issue. I am currently trying to create a more minimal reproducer to make this easier to verify as an SRU'able fix.

[0] https://github.com/tmux/tmux/commit/ab6f0bb3485f6626bad6f585e4d17059fe4f7152

description: updated
Dan Watkins (daniel-thewatkins) wrote :

OK, I've created the SRU template now I've found an easy reproducer.

The upstream commit was first included in 2.7, so anything after bionic should already contain the fix. A rough examination of upstream's git history suggests the memory leak was introduced in tmux 2.4, which is younger than xenial. So I think bionic is the only affected release here.

Changed in tmux (Ubuntu Bionic):
assignee: nobody → Dan Watkins (daniel-thewatkins)
Changed in tmux (Ubuntu):
status: New → Invalid
assignee: Dan Watkins (daniel-thewatkins) → nobody
Dan Watkins (daniel-thewatkins) wrote :

Andreas pointed out a couple of issues with my git commits (thanks!) so I've re-pushed to https://code.launchpad.net/~daniel-thewatkins/ubuntu/+source/tmux/+git/tmux/+ref/lp1835439

Hello Dan, 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.2 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: New → Fix Committed
tags: added: verification-needed verification-needed-bionic
Dan Watkins (daniel-thewatkins) wrote :

I have used the reproduction instructions to confirm that the patched tmux no longer exhibits the same memory leaking behaviour.

Specifically, I launched two containers: one for the -proposed fix and one as a control. After ~10 minutes of uptime, the non-patched tmux has grown from 2948kB RSS to 3864kb RSS whereas the patched tmux has grown from 2920kB to 2948kB.

Marking this as verification-done.

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic

The verification of the Stable Release Update for tmux has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package tmux - 2.6-3ubuntu0.2

---------------
tmux (2.6-3ubuntu0.2) bionic; urgency=medium

  * d/p/tmux-format_expand-leak.patch: Do not leak memory when working out job
    name in formats. (LP: #1835439)
  * Update maintainer to reflect Ubuntu delta.

 -- Daniel Watkins <email address hidden> Thu, 04 Jul 2019 15:45:07 -0400

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

Other bug subscribers