microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.66k stars 29.05k forks source link

symlink loop causes max cpu usage #137478

Closed jeffr-spire closed 2 years ago

jeffr-spire commented 2 years ago

Issue Type: Bug

This happens when using ssh remote to a linux VM from a mac laptop.

  1. ssh to VM in a plain shell

  2. Create the following directory structure:

    symlink-bug
    +-- root
    |   +-- base1
    |   |   +-- root -> ../../root
    |   +-- base2
    |       +-- root -> ../../root
    +-- other
    +-- root -> ../root

    commands: $ mkdir symlink-bug $ cd symlink-bug $ mkdir root root/base1 root/base2 other $ ln -s ../../root root/base1 $ ln -s ../../root root/base2 $ ln -s ../root other

  3. connect to the VM in vscode using ssh-remote, browse to and select the top-level "symlink-bug" directory to open. Confirm the prompts to open the directory in trusted mode.

Result: a node process will start up looping through the symlinks using 100% cpu for at least several minutes. The process shows up as /myhome/.vscode-server/bin/ccbaa2d27e38e5afa3e5c21c1c7bef4657064247/node /myhome/.vscode-server/bin/ccbaa2d27e38e5afa3e5c21c1c7bef4657064247/out/bootstrap-fork --type=watcherServiceChokidar

Using strace, you can see that the process is crawliing deep into the structure: [pid 1652707] statx(AT_FDCWD, "/myhome/symlink-bug/other/root/base2/root/base2/root/base2/root/base2/root/base2/root/base1/root/base1/root/base1/root/base1/root/base2/root/base2/root/base2/root/base1/root/base2/root/base1/root/base2/root/base1",

VS Code version: Code 1.62.3 (ccbaa2d27e38e5afa3e5c21c1c7bef4657064247, 2021-11-17T07:59:13.865Z) OS version: Darwin x64 19.6.0 Restricted Mode: No Remote OS version: Linux x64 5.4.0-88-generic

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz (8 x 2800)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|4, 3, 3| |Memory (System)|16.00GB (0.02GB free)| |Process Argv|| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: vm| |OS|Linux x64 5.4.0-88-generic| |CPUs|Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz (3 x 2807)| |Memory (System)|3.84GB (2.35GB free)| |VM|100%|
Extensions (2) Extension|Author (truncated)|Version ---|---|--- remote-ssh|ms-|0.66.1 remote-ssh-edit|ms-|0.66.1
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 pythontb:30283811 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 dockerwalkthru:30377721 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedt:30391933 pythonvspyt187:30373474 vsqsis200:30402083 vsaa593:30376534 vssld246cf:30401891 ```
bpasero commented 2 years ago

Can you try to reproduce with our nightly insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/

jeffr-spire commented 2 years ago

The insiders build did not go to 100% on my test case so it looks better there.

However, after enabling extension ms-vscode.cmake-tools (and with a CMakeLists.txt somewhere in the project) the 100% cpu crawling through a symlink tree returned.

bpasero commented 2 years ago

They are probably using their own file watcher.