Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode leaking tty fd's #182212

Open
cpuguy83 opened this issue May 11, 2023 · 7 comments
Open

vscode leaking tty fd's #182212

cpuguy83 opened this issue May 11, 2023 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending macos Issues with VS Code on MAC/OS X terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Milestone

Comments

@cpuguy83
Copy link

Does this issue occur when all extensions are disabled?: TBD

  • VS Code Version:
Version: 1.78.1
Commit: 6a995c4f4cc2ced6e3237749973982e751cb0bf9
Date: 2023-05-04T10:01:22.349Z (1 wk ago)
Electron: 22.5.1
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.4.0
Sandboxed: No
  • OS Version:

macOS 13.3.1 (a) (22E772610a)

Steps to Reproduce:

I've had this happen twice now, once today and last time was on May 5th.
I try to connect to my remote session and I get this:

image

I try to jump into my macOS terminal, which I typically always have open anyway and run some commands, ssh works fine of course, perplexed... I wound up trying to open a new tab with a new terminal and it fails...
After much digging I find this:

% lsof | grep /dev/ptmx | grep Code | wc -l
     510

vscode is using all of my available TTY fd's.
This happened in the course of 2 days (I rebooted the machine 2 days ago).
It is worth noting right now I have 3 vscode windows open, all disconnected from the remote.
Closing all vscode windows (but with the vscode process still running as happens on macOS until you cmd+q it) does not change this number.
Actually quitting vscode gives me all my tty fd's back.

(let's assume from now on when I say fd I'm referring to /dev/ptmx fd's)

On a brand new vscode instance (no remote connection or anything), just a window open there are 0 open fd's from vscode.
Opening one terminal in vscode there are now 2 fd's opened.
After closing that terminal there is 1 fd open.
Opening a new terminal there are 3 fd's open.
Closing that terminal there are 2 fd's open now.
Open a new terminal and there are now 4 fd's (seeing a pattern here).
Opening a 2nd terminal there are 6 fd's open.
Close that 2nd terminal 5 fd's.
Connect to a remote, which automatically opens a new terminal, 8 fd's.
Close the remote terminal, still 8 fd's open.
Open a new remote terminal, still 8 fd's open (some re-use here?)
Open 3 more remote terminals, still 8 fd's open.
Go back to the original local window and open a remote project, 10 fd's open. (seems remote's share the same local fd's between terminals in one window)
Close that window, create a new window and open the same remote project, 13 fd's open.
Closing all open windows (but keeping vscode running) still 13 fd's open
Open a new window connected to the same remote+project, 16 fd's open.

Based on this pattern it looks like:

  • Local terminals leak 1 fd per terminal after closing
  • Remote terminals share the same 2 local fd's for all terminals in one window
  • New windows connected to the same remote get new fd's
  • fd's attached to remote terminals are never closed until vscode as a whole is closed.
@Tyriar
Copy link
Member

Tyriar commented May 12, 2023

Reported in the past here: #58814

@deepak1556 + @rzhao271 you might know how to fix this?

@Tyriar Tyriar assigned deepak1556 and rzhao271 and unassigned Tyriar May 12, 2023
@Tyriar Tyriar added the terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. label May 12, 2023
@cpuguy83
Copy link
Author

I logged in this morning to find all my TTY fd's used up again.
I definitely did not have anywhere close to that much churn yesterday, so it seems like there's something else at play in vscode.
Maybe something related to disconnected remote sessions?

@deepak1556
Copy link
Collaborator

This might be a regression from microsoft/node-pty#589, will investigate.

@deepak1556 deepak1556 added bug Issue identified by VS Code Team member as probable bug upstream Issue identified as 'upstream' component related (exists outside of VS Code) macos Issues with VS Code on MAC/OS X confirmation-pending labels May 13, 2023
@deepak1556 deepak1556 added this to the May 2023 milestone May 13, 2023
@RblSb
Copy link

RblSb commented May 16, 2023

I can confirm that used ttys count is incremented with every task execution (count can be seen in macos terminal new window/tab). After ~450 build tasks you cannot even create real terminal window without restarting vscode to free stuff again.
Let me know if you need repro setup for it, maybe it depends on my tasks/extensions.

@deepak1556 deepak1556 modified the milestones: May 2023, June 2023 May 29, 2023
@RblSb
Copy link

RblSb commented Jun 11, 2023

Current workaround how to clean tty count without restarting vscode everyday:

  • execute ps -ef | grep tty
    It will show list like:
  501 73743 67324   0  8:39AM ttys442    0:00.04 /bin/zsh -il
    0 75870 73743   0 12:03PM ttys442    0:00.01 ps -ef
  501 75871 73743   0 12:03PM ttys442    0:00.00 grep tty

Then you need to kill 67324 (but other value from this position in list) to restart terminal and clean it.
So vscode undo/redo history is saved and you can continue your work.

@deepak1556 deepak1556 modified the milestones: June 2023, July 2023 Jun 23, 2023
@joaomoreno joaomoreno modified the milestones: July 2023, August 2023 Jun 29, 2023
@RblSb
Copy link

RblSb commented Aug 29, 2023

Please pay attention to this regression between 1.77.3 and 1.78.0.

@deepak1556 deepak1556 removed this from the September 2023 milestone Sep 25, 2023
@deepak1556 deepak1556 added this to the October 2023 milestone Sep 25, 2023
@RblSb
Copy link

RblSb commented Dec 19, 2023

Still not fixed. Every build task run on macos allocates new virtual terminal, after day of build runs you will need to restart vscode. Very annoying.
image

@deepak1556 please, at least add regression tag and remove confirmation-pending if you can repro this:
echo.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending macos Issues with VS Code on MAC/OS X terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

8 participants