microsoft / vscode

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

Incorrect crash event fired for termination of filewatcher by SIGTERM #186540

Closed SimonSiefke closed 5 months ago

SimonSiefke commented 1 year ago

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

Steps to Reproduce:

  1. Open an empty folder in vscode
  2. Set this as workspace settings json:
{
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/.hg/store/**": true,
    "**/.vscode-test-workspace/**": true,
    "**/.vscode-user-data-dir/**": true,
    "**/dist/**": true,
    "**/fixtures/**": true
  }
}
  1. Open the Main Output channel
  2. An error message is dispayed in the output channel: [error] [UtilityProcess id: 1, type: fileWatcher, pid: 28113]: crashed with code 15 and reason 'killed'

See also detailed reproduction steps in https://github.com/SimonSiefke/vscode-file-watcher-crashed

Complete Main Output Channel Logs

2023-06-28 20:16:26.396 [info] update#setState idle
2023-06-28 20:16:30.591 [error] [UtilityProcessWorker]: terminated unexpectedly with code 15, signal: unknown
2023-06-28 20:16:30.592 [error] [UtilityProcess id: 1, type: fileWatcher, pid: 28113]: crashed with code 15 and reason 'killed'
2023-06-28 20:16:30.593 [info] Extension host with pid 28133 exited with code: 0, signal: unknown.
2023-06-28 20:16:56.399 [info] update#setState checking for updates
2023-06-28 20:16:56.403 [info] update#setState idle

Expected behaviour

The file watcher doesn't crash.

Actual behaviour

The file watcher crashes with code 15.

shijunti19 commented 1 year ago

The memory leakage of vscode is too severe, I hope to roll back several versions

It has become so severe that it cannot be used

bpasero commented 1 year ago

I cannot reproduce.

Can you please follow the steps in https://github.com/Microsoft/vscode/wiki/Native-Crash-Issues to get at more details around the crash and attach the result here? Thanks!

SimonSiefke commented 1 year ago

Please check out this screencast of the issue:

And here is the crash dump:

vscode-file-watcher-crash-dump.zip

I hope this helps!

rzhao271 commented 1 year ago

Symbolicated

symbolicated-6c.log

bpasero commented 1 year ago
code!blink::mojom::internal::WebPreferences_Data::Validate(void const*, mojo::internal::ValidationContext*) [validation_util.h : 0 + 0x8]
code!content::(anonymous namespace)::FileSystemEntryURLLoader::~FileSystemEntryURLLoader() [sequenced_task_runner.h : 216 + 0xd]
code!perfetto::trace_processor::tables::GpuSliceTable::GpuSliceTable(perfetto::trace_processor::StringPool*, perfetto::trace_processor::tables::SliceTable*) [nullable_vector.h : 169 + 0x11]
code!media::mojom::internal::CodecMetadata_Data::Validate(void const*, mojo::internal::ValidationContext*, bool) [video_encode_accelerator.mojom-shared.cc : 196 + 0x2]
code!media::mojom::internal::CodecMetadata_Data::Validate(void const*, mojo::internal::ValidationContext*, bool) [video_encode_accelerator.mojom-shared.cc : 0 + 0x3]
...

Somehow I feel this stack is unrelated to the issue at hand 🤔

OrkunTokdemir commented 1 year ago

I get this error too when I run tests. I just initialized a vscode extension according to https://code.visualstudio.com/api/get-started/your-first-extension. If I run npm run test, I get the below crash error. image

Version: 1.83.1
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:45:31.402Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.2.0-34-generic
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
Spyabo commented 1 year ago

Opening a vscode window that contains a jupyter notebook .ipynb file causes the window to crash after loading image Here are the main logs related to the crash:

2023-10-19 11:34:38.693 [error] [UtilityProcessWorker]: terminated unexpectedly with code 15, signal: unknown
2023-10-19 11:34:38.694 [error] [UtilityProcess id: 2, type: fileWatcher, pid: 20000]: crashed with code 15 and reason 'killed'
2023-10-19 11:34:38.695 [error] ptyHost terminated unexpectedly with code 0
2023-10-19 11:34:38.696 [error] [UtilityProcessWorker]: terminated unexpectedly with code 15, signal: unknown
2023-10-19 11:34:38.696 [error] [UtilityProcess id: 1, type: fileWatcher, pid: 19602]: crashed with code 15 and reason 'killed'
2023-10-19 11:34:38.697 [error] [UtilityProcess type: shared-process, pid: 19601]: crashed with code 15 and reason 'killed'
2023-10-19 11:34:38.704 [info] Extension host with pid 20001 exited with code: 0, signal: unknown.
2023-10-19 11:34:38.704 [error] [UtilityProcess id: 2, type: extensionHost, pid: 20001]: crashed with code 15 and reason 'killed'
2023-10-19 11:34:38.705 [error] CodeWindow: renderer process gone (reason: killed, code: 15)
2023-10-19 11:34:38.994 [error] CodeWindow: renderer process gone (reason: killed, code: 15)
2023-10-19 11:34:39.278 [info] Extension host with pid 19603 exited with code: 15, signal: unknown.
2023-10-19 11:34:39.281 [error] [UtilityProcess id: 1, type: extensionHost, pid: 19603]: crashed with code 15 and reason 'killed'
ProductName: macOS
ProductVersion: 13.5.1
BuildVersion: 22G90
AngeloGross commented 1 year ago

I've got the same issue opening .ipynb files, but only when the Jupyter Extension is enabled. Specifically, when I create a new .ipynb file, it crashes - without a message.

The main log file states:

2023-10-19 15:03:44.203 [info] update#setState idle
2023-10-19 15:03:48.057 [error] [UtilityProcess type: shared-process, pid: 3461]: crashed with code 15 and reason 'killed'
2023-10-19 15:03:48.059 [info] Extension host with pid 3432 exited with code: 15, signal: unknown.
2023-10-19 15:03:48.059 [error] [UtilityProcess id: 1, type: extensionHost, pid: 3432]: crashed with code 15 and reason 'killed'
2023-10-19 15:03:48.082 [error] CodeWindow: renderer process gone (reason: clean-exit, code: <unknown>)
2023-10-19 15:03:48.226 [error] [UtilityProcess id: 1, type: fileWatcher, pid: 3462]: crashed with code 15 and reason 'killed'

OS: Ubuntu 22.04 VSCode:

1.83.1
f1b07bd25dfad64b0167beb15359ae573aecd2cc
x64
rzhao271 commented 1 year ago

@Spyabo @AngeloGross could both of you generate and attach crash reports? The last one at https://github.com/microsoft/vscode/issues/186540#issuecomment-1615002022 might have been invalid. See https://github.com/Microsoft/vscode/wiki/Native-Crash-Issues for instructions

DonJayamanne commented 1 year ago

This looks like a duplicate of https://github.com/microsoft/pylance-release/issues/4986

@AngeloGross @Spyabo @OrkunTokdemir @shijunti19 @SimonSiefke Please revert the version of Pylance extesnion to the previous version. If that works, then we can close this issue as a duplicate

AngeloGross commented 1 year ago

@DonJayamanne I actually already installed an older version of VSCode (1.75.1) and it is working now. Which exact version of the pylance extension is making problems? Which previous version should be used?

anthony-langford commented 1 year ago

Same issue here image

Version: 1.83.1 (Universal) Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:46:55.789Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.0.0

DonJayamanne commented 1 year ago

@anthony-langford @AngeloGross @Spyabo Please could you try installing the previous version of Pylance extension, thats 2023.10.20 Let me know if that works.

AngeloGross commented 1 year ago

@DonJayamanne I installed 2023.10.20 and the problem disappeared. Reinstalled the latest version 2023.10.30 and the problem reappeared. In my opinion, it seems that there is a bug in 2023.10.30.

cgebbe commented 1 year ago

@DonJayamanne : Thanks for the tip, seems that it works now with pylance 2023.10.20 !

rebornix commented 12 months ago

For the crashes caused by Pylance, it's now fixed in latest Pylance release 2023.10.40. You can follow steps in https://github.com/microsoft/vscode/issues/195617#issuecomment-1773202568 to get it updated.

Spyabo commented 12 months ago

@anthony-langford @AngeloGross @Spyabo Please could you try installing the previous version of Pylance extension, thats 2023.10.20 Let me know if that works.

I switched to the pre-release python extension in VSCode and it's all working again

deepak1556 commented 11 months ago

@SimonSiefke can you confirm if the crash is present with 1.84.0, I am unable to confirm with the repro provided.

SimonSiefke commented 11 months ago

I can still reproduce with v1.84.0:

https://github.com/microsoft/vscode/assets/23744935/6d1ee4b6-68c5-4742-804b-10a8b3d280d9

I'm hoping the screencast helps. Sometimes the window needs to be reloaded several times before the log appears file watcher crashed with code 15.

jetm commented 6 months ago

This is still happening with code-insiders and without pylance. It's easy to reproduce by just closing VSCode.

", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (1632)
[331296:0326/193211.324464:INFO:CONSOLE(1632)] "console.groupEnd", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (1632)
[main 2024-03-27T01:32:11.841Z] resolveShellEnv(): skipped (VSCODE_CLI is set)
[main 2024-03-27T01:32:11.874Z] Lifecycle#window.on('close') - window ID 4
[main 2024-03-27T01:32:11.874Z] Lifecycle#unload() - window ID 4
[331296:0326/193211.874987:INFO:CONSOLE(651)] "%cTRACE color: #888 [lifecycle] onBeforeUnload (reason: 1)", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (651)
[331296:0326/193211.876498:INFO:CONSOLE(651)] "%cTRACE color: #888 [lifecycle] onBeforeUnload continues without veto", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (651)
[331296:0326/193211.876714:INFO:CONSOLE(651)] "%cTRACE color: #888 [lifecycle] onWillUnload (reason: 1)", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (651)
[331296:0326/193211.877885:INFO:CONSOLE(651)] "%cDEBUG background: #eee; color: #888 Comments: URIs of continue on comments to add to storage .", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (651)
[main 2024-03-27T01:32:11.880Z] [UtilityProcess id: 8, type: extensionHost, pid: 333040]: received exit event with code 0
[main 2024-03-27T01:32:11.880Z] Extension host with pid 333040 exited with code: 0, signal: unknown.
[main 2024-03-27T01:32:11.881Z] Lifecycle#onBeforeCloseWindow.fire() - window ID 4
[main 2024-03-27T01:32:11.882Z] IPC Object URL: Removed channel vscode:cf2fcd17-8104-491f-80d1-e707af38ebf7.
[main 2024-03-27T01:32:11.883Z] Lifecycle#window.on('closed') - window ID 4
[main 2024-03-27T01:32:11.883Z] [UtilityProcess id: 4, type: fileWatcher, pid: 333008]: attempting to kill the process...
[main 2024-03-27T01:32:11.883Z] [UtilityProcess id: 4, type: fileWatcher, pid: 333008]: successfully killed the process
[main 2024-03-27T01:32:11.886Z] [UtilityProcess id: 4, type: fileWatcher, pid: 333008]: received exit event with code 0
[main 2024-03-27T01:32:11.886Z] [UtilityProcessWorker]: terminated normally with code 0, signal: unknown
[main 2024-03-27T01:32:11.886Z] [UtilityProcess id: 4, type: fileWatcher, pid: 333008]: crashed with code 15 and reason 'killed'
[main 2024-03-27T01:32:11.889Z] [UtilityProcess id: 7, type: extensionHost, pid: 333019]: received exit event with code 0
[main 2024-03-27T01:32:11.889Z] Extension host with pid 333019 exited with code: 0, signal: unknown.
[331296:0326/193211.919281:INFO:CONSOLE(651)] "%cTRACE color: #888 Layout#layout, height: 1438, width: 1278", source: vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/workbench/workbench.desktop.main.js (651)
[main 2024-03-27T01:32:12.097Z] menubarService#updateMenubar 1

I am using

    "files.watcherExclude": {
        "**": true
    }
bpasero commented 6 months ago

Some more investigation today indicates that using utilityProcess.kill() ends up sending an exit code of 15 in certain cases on Linux, at least in VS Codes usages. I am pushing a change to not wrongfully treat this as abnormal termination by keeping track of when we called kill and treating an exit code of 15 as 0 in that case.

jetm commented 6 months ago

@bpasero Thank you for fixing this. How do we test it? It should not be closed so quickly; at least give us a chance to test it.

connor4312 commented 5 months ago

@jetm you can try this out on VS Code Insiders: https://code.visualstudio.com/insiders/

bpasero commented 5 months ago

I am removing the bug label, this was never a real bug (as far as I can tell), but our assumption was wrong. According to @deepak1556 , calling utilityProcess.kill() will trigger a SIGTERM (exit code 15) which we wrongly assumed as being a unexpected crash. I leave it up to him to consider this as something to change in Electron.

I will validate my change next month based on telemetry results where we track utility process crashes, but if someone from the people in this issue see a difference or still believe something is wrong, please speak up.

jetm commented 5 months ago

I have tried insiders 1714024193, and the crash is still happening. I attached the *.dmp files. vscode-insiders.zip

@bpasero I still think this is a bug, and it should be treated as one. No crash should happen just by quitting it.

bpasero commented 5 months ago

Thanks, I think I should have not hijacked this issue then if there is still a crash happening, reopening.

bpasero commented 5 months ago

@jetm can you share more details how to exactly reproduce, your setup, your OS, etc.?

deepak1556 commented 5 months ago

I think there is some confusion, the issue has two unrelated crashes being combined.

1) Filewatcher crash with code 15 - this was due to an incorrect crashed event being fired from the runtime when the process was killed by SIGTERM. @bpasero set out to address this and additionally there will not be any crash dumps generated as it is not a crash in the first place.

2) Crash reported by @jetm , I have separated it out to https://github.com/microsoft/vscode/issues/211422 as it is unrelated to the file watcher. @jetm can you comment in that issue with the data for https://github.com/microsoft/vscode/issues/186540#issuecomment-2078675731. Thanks!