Skip to content

Crash (OOM) on debugging #2173

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

Open
segevfiner opened this issue Feb 19, 2025 · 15 comments · Fixed by #2179
Open

Crash (OOM) on debugging #2173

segevfiner opened this issue Feb 19, 2025 · 15 comments · Fixed by #2179
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug

Comments

@segevfiner
Copy link
Contributor

Describe the bug
The extension host crashes on debugging (Another reproduction of #1911). Unfortunately this is a proprietary project so I can't share an immediate reproduction, but I'll share whatever I can that can help pinpoint what causes the crash.

To Reproduce
Steps to reproduce the behavior:

  1. Try to debug JavaScript in a project with very large source maps.

Log File

vscode-debugadapter-f7de7273.json

VS Code Version: 1.97.2

Additional context

Another reproduction of #1911

@segevfiner segevfiner added the bug Issue identified by VS Code Team member as probable bug label Feb 19, 2025
@karolis-zukauskas
Copy link

Here is minimal reproduction repo: https://github.com/karolis-zukauskas/js-debug-sourcemap-oom

See comments in README.

@connor4312
Copy link
Member

Thanks, that was quite helpful. @segevfiner wonder if this fixes your use case too.

@connor4312 connor4312 added this to the March 2025 milestone Mar 7, 2025
@segevfiner
Copy link
Contributor Author

@connor4312 Did it reach the nightly yet? I'll play around and let you know if it happens again.

@connor4312
Copy link
Member

It should be on the latest version

@amunger amunger added the author-verification-requested Issues potentially verifiable by issue author label Mar 26, 2025
@amunger
Copy link

amunger commented Mar 26, 2025

@segevfiner - were you able to verify if this was resolved?

@segevfiner
Copy link
Contributor Author

I didn't encounter this again just yet, but my reproduction was always rather sporadic. I'll open a new issue if I hit the problem again.

@connor4312 connor4312 added the verified Verification succeeded label Mar 26, 2025
@karolis-zukauskas
Copy link

@amunger for me the crashes are gone with nightly. Last day I switched back to stable because there seems to be a new separate issue with nightly and the crashes immediately reappeared, so I guess this PR does indeed fix the OOM issue.

@segevfiner
Copy link
Contributor Author

Managed to reproduce on nightly unfortunately:

vscode-debugadapter-d76d65d3.json

Let me know if you want to reopen this or for me to open another issue.

@connor4312 connor4312 reopened this Mar 27, 2025
@connor4312 connor4312 removed the verified Verification succeeded label Mar 27, 2025
@connor4312 connor4312 removed this from the March 2025 milestone Mar 27, 2025
@jeremysf
Copy link

jeremysf commented May 23, 2025

I get this constantly when trying to debug by attaching to node in our applications.

It happens in our apps and our jest tests.

We are running in a devcontainer.

I have disabled DWARF debugging info, but I suspect it has to do with our extensive use of WebAssembly.

Is there any way to increase the memory given to the extension host?

2025-05-23 16:48:18.042 [info] Getting Manifest... ms-vscode.js-debug-nightly
2025-05-23 16:48:18.175 [info] Installing extension: ms-vscode.js-debug-nightly {"isMachineScoped":false,"installPreReleaseVersion":false,"pinned":false,"donotVerifySignature":false,"context":{"clientTargetPlatform":"darwin-arm64"},"isApplicationScoped":false,"profileLocation":{"$mid":1,"fsPath":"/home/vscode/.vscode-server/extensions/extensions.json","external":"file:///home/vscode/.vscode-server/extensions/extensions.json","path":"/home/vscode/.vscode-server/extensions/extensions.json","scheme":"file"},"productVersion":{"version":"1.100.2","date":"2025-05-14T21:47:40.416Z"}}
2025-05-23 16:48:19.251 [info] Extension signature verification result for ms-vscode.js-debug-nightly: Success. Internal Code: 0. Executed: true. Duration: 732ms.
2025-05-23 16:48:19.283 [info] Extracted extension to file:///home/vscode/.vscode-server/extensions/ms-vscode.js-debug-nightly-2025.5.1617: ms-vscode.js-debug-nightly
2025-05-23 16:48:19.293 [info] Renamed to /home/vscode/.vscode-server/extensions/ms-vscode.js-debug-nightly-2025.5.1617
2025-05-23 16:48:19.330 [info] Extension installed successfully: ms-vscode.js-debug-nightly file:///home/vscode/.vscode-server/extensions/extensions.json
2025-05-23 16:48:43.886 [info] [127.0.0.1][6b01c953][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.
2025-05-23 16:48:44.014 [info] [127.0.0.1][36507063][ExtensionHostConnection] <2337520> Extension Host Process exited with code: 0, signal: null.
2025-05-23 16:48:50.065 [info] [127.0.0.1][8b24281b][ManagementConnection] New connection established.
2025-05-23 16:48:50.478 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] New connection established.
2025-05-23 16:48:50.517 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824> Launched Extension Host Process.
2025-05-23 16:51:11.954 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 
<--- Last few GCs --->

[2346824:0x1d3c66a0]   141390 ms: Mark-Compact 4044.0 (4143.6) -> 4044.0 (4143.6) MB, 42.30 / 0.00 ms  (average mu = 0.128, current mu = 0.008) allocation failure; scavenge might not succeed
[2346824:0x1d3c66a0]   141433 ms: Mark-Compact 4044.5 (4144.1) -> 4044.5 (4144.1) MB, 42.64 / 0.00 ms  (average mu = 0.071, current mu = 0.009) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----


2025-05-23 16:51:11.954 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  1: 0xb8cf03 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.955 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  2: 0xf04140 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.955 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  3: 0xf04427 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.956 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  4: 0x1116075  [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.956 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  5: 0x112def8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.956 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  6: 0x1104011 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.957 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  7: 0x11051a5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.957 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  8: 0x10e18c6 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.958 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr>  9: 0x10d34f4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.958 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 10: 0x10d5cd6 v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString(int, v8::internal::AllocationType) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.959 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 11: 0x10eccf4 v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.959 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 12: 0xf169d2 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.959 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 13: 0xdefa37  [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.960 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 14: 0xdefb6f node::StringDecoder::DecodeData(v8::Isolate*, char const*, unsigned long*) [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]

2025-05-23 16:51:11.960 [info] [127.0.0.1][3f6ef0e0][ExtensionHostConnection] <2346824><stderr> 15: 0xdf00ad  [/vscode/vscode-server/bin/linux-x64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e/node]
16: 0x770ba7e4d546 

@connor4312
Copy link
Member

I have disabled DWARF debugging info, but I suspect it has to do with our extensive use of WebAssembly.

To clarify, you see this issue resolved when you disable DWARF debug info?

@jeremysf
Copy link

No, the issue exists with DWARF debug info disabled.

@jeremysf
Copy link

Maybe I'm mis-understanding how to carve out files or maybe it has nothing to do with source maps?

The workspace is a monorepo with a few million lines of code, service oriented architecture backend and a WebGL/WASM based frontend (a collaborative electronics CAD application).

I'm using @swc/jest as the transformer for the TypeScript files attempting to be tested.

{
            "type": "node",
            "request": "attach",
            "name": "Attach to Test",
            "port" : 9227,
            "enableDWARF": false,
            "resolveSourceMapLocations": [
                "!${workspaceFolder}/**",
                "!**/node_modules/**",
                "!**/*.wasm_",
                "!packages/common/wasm/**"
            ] 
        },

@connor4312
Copy link
Member

connor4312 commented May 23, 2025

I'll look into it. We do decompile WASM->WAT regardless of enableDWARF. I try not to do that eagerly but the structure of DAP requires us to do it more often than I would like. So that could be a contributing factor.

I should PR a "take heap snapshot" button into vscode's extension view to make it easier for people to help collect memory data 😄

@segevfiner
Copy link
Contributor Author

Is there currently a way to take a heap snapshot? I can try and do that next time I manage to reproduce, though I will need to get approval from my employer to share it privately with you due to size and risk of confidential content in such a dump...

@connor4312
Copy link
Member

connor4312 commented May 23, 2025

A bit annoying but the way to do it without setup is

  1. Run "Show Running Extensions" and hit the "take extension host profile" button and then just stop it. This'll cause the inspector to open for the extension host on port 9229
Image
  1. Either use devtools edge://inspect or the JS debugger in another window to attach to localhost:9229
  2. Take a heap snapshot (Take Performance Profile > Heap Snapshot in js-debug). Note that this can take a few minutes to collect, but once it's ready it'll save a .heapsnapshot file to your workspace folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants