-
Notifications
You must be signed in to change notification settings - Fork 244
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
VS Code leaks open file descriptors to subprocesses in terminal #499
Comments
Today I found vscode had leaked 168 file descriptors into my terminal, pointing to lots of Chromium shared memory segments, V8 snapshot, fonts, other static assets, etc. I think its important that vscode fix this by closing all FDs greater than 2 before exec'ing the terminal. Developers commonly run buggy work-in-progress code in their terminal, and it would be pretty easy for buggy code to accidentally write to one of these FDs causing who-knows-what effects to vscode. As a work-around I can close all unexpected FDs by executing this command:
(Note that in addition to stdin/stdout/stderr, this keeps fd 255 open. Bash apparently stores a dup of the terminal into fd 255 and uses it for various things, so if you close it, it causes trouble.) |
FYI @deepak1556 /duplicate microsoft/vscode#58814 |
@Tyriar It appears microsoft/vscode#58814 was closed on the basis that this is not a security bug. I mostly agree with that, however, it is still most certainly a bug. Leaving file descriptors in the FD table when spawning subprocesses is considered bad behavior. At best it's sloppy, but at worst it can cause problems. Some examples of problems:
While the ideal solution would be for vscode to open file descriptors with * File descriptor numbers aren't limited to 1024, but the OS always uses the lowest possible number for any new descriptor, so it's unusual for them to get very high. |
I do not remember in which context I opened this issue and if it was a real problem... Maybe since I work with shared memory in app it was confusing to get extra open descriptors and harder to debug. Just a comment about closing in a loop: I think kernel has a specific syscall for it or close_range libc function. |
|
@kentonv this is a bit out of my depth tbh but would welcome a PR to https://github.com/microsoft/node-pty to fix it as I think that's where the fix would go. |
See this issue for details: microsoft/node-pty#499 Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
See this issue for details: microsoft/node-pty#499 Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com> Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com>
See this issue for details: microsoft/node-pty#499 Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com> Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com>
See this issue for details: microsoft/node-pty#499 Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com> Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com>
See this issue for details: microsoft/node-pty#499 Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com> Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com>
See this issue for details: microsoft/node-pty#499 Co-authored-by: Szilard Parrag <szilard.parrag@axoflow.com> Co-authored-by: Attila Szakacs <attila.szakacs@axoflow.com> Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
We have written the needed data into your clipboard because it was too large to send. Please paste.
Issue Type: Bug
sudo lsof -p $(/sbin/pidof top)
Apparently VS Code leaks some files open without CLOEXEC flag:
Plus some chromium stuff like fonts and files on /dev/shm
VS Code version: Code 1.37.1 (f06011ac164ae4dc8e753a3fe7f9549844d15e35, 2019-08-15T16:17:25.463Z)
OS version: Linux x64 3.10.0-957.10.1.el7.x86_64
System Info
flash_3d: disabled_software
flash_stage3d: disabled_software
flash_stage3d_baseline: disabled_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: disabled_software
viz_display_compositor: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Extensions (12)
(2 theme extensions excluded)
The text was updated successfully, but these errors were encountered: