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

Memory leak in parser module #351

Open
xiaonuozi opened this issue Oct 8, 2024 · 15 comments
Open

Memory leak in parser module #351

xiaonuozi opened this issue Oct 8, 2024 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@xiaonuozi
Copy link

<--- Last few GCs --->

[27192:0000461800324000] 66116 ms: Mark-Compact 3841.4 (4090.7) -> 3832.3 (4089.7) MB, pooled: 6 MB, 6932.87 / 0.00 ms (average mu = 0.260, current mu = 0.098) allocation failure; scavenge might not succeed
[27192:0000461800324000] 76598 ms: Mark-Compact 3841.2 (4090.2) -> 3836.8 (4092.7) MB, pooled: 3 MB, 10427.22 / 0.00 ms (average mu = 0.117, current mu = 0.005) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF6EF7F26BA uv_cpumask_size+72282
2: 00007FF6EF76D47A node::OnFatalError+730
3: 00007FF6F276CBB4 v8::Function::NewInstance+868
4: 00007FF6F276CB23 v8::Function::NewInstance+723
5: 00007FF6F281E777 v8::CppHeap::wrapper_descriptor+61447
6: 00007FF6EE38342C v8::CppHeap::CollectStatistics+255964
7: 00007FF6EE382DBC v8::CppHeap::CollectStatistics+254316
8: 00007FF6EE3829F0 v8::CppHeap::CollectStatistics+253344
9: 00007FF6EE388769 v8::CppHeap::CollectStatistics+277273
10: 00007FF6F0A30075 uv_random+5685
11: 00007FF6F0A30402 uv_random+6594
12: 00007FF6EE384B30 v8::CppHeap::CollectStatistics+261856
13: 00007FF6EE375DE3 v8::CppHeap::CollectStatistics+201107
14: 00007FF6EE36FE73 v8::CppHeap::CollectStatistics+176675
15: 00007FF6EE35F18A v8::CppHeap::CollectStatistics+107834
16: 00007FF6EE35E6C9 v8::CppHeap::CollectStatistics+105081
17: 00007FF6EE367FFE v8::CppHeap::CollectStatistics+144302
18: 00007FF6EE367C64 v8::CppHeap::CollectStatistics+143380
19: 00007FF6EE613925 cppgc::internal::WriteBarrier::SteeleMarkingBarrierSlow+2661
[Error - 3:57:24 PM] Server process exited with code 134.
[Info - 3:57:24 PM] Connection to server got closed. Server will restart.
true

<--- Last few GCs --->

[27544:00000D1000324000] 76166 ms: Scavenge (interleaved) 3843.8 (4086.7) -> 3841.9 (4090.2) MB, pooled: 5 MB, 136.06 / 0.00 ms (average mu = 0.183, current mu = 0.006) allocation failure;
[27544:00000D1000324000] 84850 ms: Mark-Compact 3848.6 (4091.7) -> 3844.4 (4095.2) MB, pooled: 1 MB, 8663.65 / 0.00 ms (average mu = 0.101, current mu = 0.027) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF6EF7F26BA uv_cpumask_size+72282
2: 00007FF6EF76D47A node::OnFatalError+730
3: 00007FF6F276CBB4 v8::Function::NewInstance+868
4: 00007FF6F276CB23 v8::Function::NewInstance+723
5: 00007FF6F281E777 v8::CppHeap::wrapper_descriptor+61447
6: 00007FF6EE38342C v8::CppHeap::CollectStatistics+255964
7: 00007FF6EE382DBC v8::CppHeap::CollectStatistics+254316
8: 00007FF6EE3829F0 v8::CppHeap::CollectStatistics+253344
9: 00007FF6EE388769 v8::CppHeap::CollectStatistics+277273
10: 00007FF6F0A30075 uv_random+5685
11: 00007FF6F0A30402 uv_random+6594
12: 00007FF6EE384B30 v8::CppHeap::CollectStatistics+261856
13: 00007FF6EE375DE3 v8::CppHeap::CollectStatistics+201107
14: 00007FF6EE36FE73 v8::CppHeap::CollectStatistics+176675
15: 00007FF6EE35F18A v8::CppHeap::CollectStatistics+107834
16: 00007FF6EE35E6C9 v8::CppHeap::CollectStatistics+105081
17: 00007FF6EE367FFE v8::CppHeap::CollectStatistics+144302
18: 00007FF6EE367C64 v8::CppHeap::CollectStatistics+143380
19: 00007FF6EE613925 cppgc::internal::WriteBarrier::SteeleMarkingBarrierSlow+2661
[Error - 3:58:58 PM] Server process exited with code 134.
[Info - 3:58:58 PM] Connection to server got closed. Server will restart.
true

<--- Last few GCs --->

[2472:0000210C00324000] 76622 ms: Mark-Compact 3842.0 (4089.7) -> 3837.6 (4088.9) MB, pooled: 7 MB, 9984.02 / 0.00 ms (average mu = 0.126, current mu = 0.005) allocation failure; scavenge might not succeed
[2472:0000210C00324000] 84998 ms: Mark-Compact 3846.5 (4089.4) -> 3842.2 (4092.7) MB, pooled: 4 MB, 8352.56 / 0.00 ms (average mu = 0.067, current mu = 0.003) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF6EF7F26BA uv_cpumask_size+72282
2: 00007FF6EF76D47A node::OnFatalError+730
3: 00007FF6F276CBB4 v8::Function::NewInstance+868
4: 00007FF6F276CB23 v8::Function::NewInstance+723
5: 00007FF6F281E777 v8::CppHeap::wrapper_descriptor+61447
6: 00007FF6EE38342C v8::CppHeap::CollectStatistics+255964
7: 00007FF6EE382DBC v8::CppHeap::CollectStatistics+254316
8: 00007FF6EE3829F0 v8::CppHeap::CollectStatistics+253344
9: 00007FF6EE388769 v8::CppHeap::CollectStatistics+277273
10: 00007FF6F0A30075 uv_random+5685
11: 00007FF6F0A30402 uv_random+6594
12: 00007FF6EE384B30 v8::CppHeap::CollectStatistics+261856
13: 00007FF6EE375DE3 v8::CppHeap::CollectStatistics+201107
14: 00007FF6EE36FE73 v8::CppHeap::CollectStatistics+176675
15: 00007FF6EE35F18A v8::CppHeap::CollectStatistics+107834
16: 00007FF6EE35E6C9 v8::CppHeap::CollectStatistics+105081
17: 00007FF6EE367FFE v8::CppHeap::CollectStatistics+144302
18: 00007FF6EE367C64 v8::CppHeap::CollectStatistics+143380
19: 00007FF6EE613925 cppgc::internal::WriteBarrier::SteeleMarkingBarrierSlow+2661
[Error - 4:03:24 PM] Client InterSystems Language Server: connection to server is erroring.
Channel closed
[Error - 4:03:25 PM] Server process exited with code 134.
[Info - 4:03:25 PM] Connection to server got closed. Server will restart.
true

@xiaonuozi
Copy link
Author

myVScode Version
Version: 1.94.0 (user setup)
Commit: d78a74bcdfad14d5d3b1b782f87255d802b57511
Date: 2024-10-02T13:08:12.626Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

InterSystems Language Server:v2.6.2

@gjsjohnmurray
Copy link
Collaborator

I suggest you use Install Specific Version... from the gearwheel of the extension in Extensions view, picking an earlier version to see if the problem is a longstanding one or if it is recent.

@xiaonuozi
Copy link
Author

I suggest you use Install Specific Version... from the gearwheel of the extension in Extensions view, picking an earlier version to see if the problem is a longstanding one or if it is recent.

I used version v2.5.1 and it worked fine, but later versions started to produce this error

@xiaonuozi xiaonuozi reopened this Oct 8, 2024
@gjsjohnmurray
Copy link
Collaborator

Thanks @xiaonuozi. Please reopen the issue.

Pinging @isc-bsaviano who will investigate.

@isc-bsaviano
Copy link
Contributor

@xiaonuozi What are you doing when the extension crashes? Does it happen when it activates, or only when you open certain files? Do any versions after 2.5.1 work? This is a very strange error that I haven't seen before. I'll see if I can reproduce it on my windows machine.

@isc-bsaviano isc-bsaviano reopened this Oct 8, 2024
@xiaonuozi
Copy link
Author

@xiaonuozi What are you doing when the extension crashes? Does it happen when it activates, or only when you open certain files? Do any versions after 2.5.1 work? This is a very strange error that I haven't seen before. I'll see if I can reproduce it on my windows machine.

I found through testing that the issue only occurs when I open a specific .cls file. Versions after 2.5.1, such as 2.6.0, 2.6.1, and the latest 2.6.2, all exhibit this problem, with version 2.6.0 also giving a output:
[Error - 9:50:25 AM] Request textDocument/foldingRange failed.
Message: Request textDocument/foldingRange failed with message: Range#create called with invalid arguments[1304, -1, 1304, 1]
Code: -32603

@isc-bsaviano
Copy link
Contributor

@xiaonuozi Thanks for checking. That foldingRange error is probably #343, which was fixed in 2.6.1. Can you send me that class so I can reproduce the error myself? If you don't feel comfortable posting it on this public issue, you can open a WRC case and attach it there.

@RalphGauer-Paul
Copy link

RalphGauer-Paul commented Oct 30, 2024

I'm having the same problem with a ".mac" file (ca. 4200 lines).
The InterSystems Language Server version is 2.6.3.

<--- Last few GCs --->

[8972:000046B000128000] 11297829 ms: Mark-Compact 3934.8 (4080.2) -> 3927.3 (4081.0) MB, pooled: 6 MB, 7324.46 / 0.00 ms (average mu = 0.066, current mu = 0.003) allocation failure; scavenge might not succeed
[8972:000046B000128000] 11303466 ms: Mark-Compact 3936.1 (4081.0) -> 3929.7 (4083.2) MB, pooled: 3 MB, 5569.53 / 0.00 ms (average mu = 0.043, current mu = 0.012) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 00007FF612AB8DCA uv_cpumask_size+56282
2: 00007FF612A3275B node::OnFatalError+747
3: 00007FF615BA5124 v8::Function::NewInstance+868
4: 00007FF615BA5093 v8::Function::NewInstance+723
5: 00007FF615C75F77 v8::CppHeap::CollectGarbageInYoungGenerationForTesting+66807
6: 00007FF611683694 v8::CppHeap::Terminate+134340
7: 00007FF611682E0B v8::CppHeap::Terminate+132155
8: 00007FF61502894D Cr_z_adler32+5491917
9: 00007FF614297D24 v8::internal::ThreadIsolation::StartOfJitAllocationAt+348100
10: 00007FF6142931F2 v8::internal::ThreadIsolation::StartOfJitAllocationAt+328850
11: 00007FF614287A0B v8::internal::ThreadIsolation::StartOfJitAllocationAt+281771
12: 00007FF61166C785 v8::CppHeap::Terminate+40373
13: 00007FF6117A3377 v8::MemorySpan<std::__Cr::basic_string_view<char,std::__Cr::char_traits > const >::end+261079
14: 00007FF61494FEFA v8::internal::compiler::CompilationDependencies::FieldTypeDependencyOffTheRecord+2913450
15: 00007FF6148F2BCB v8::internal::compiler::CompilationDependencies::FieldTypeDependencyOffTheRecord+2531707
16: 00007FF674A27FFD
[Error - 10:26:10 AM] Server process exited with code 134.
[Info - 10:26:10 AM] Connection to server got closed. Server will restart.
true

@isc-bsaviano
Copy link
Contributor

@RalphGauer-Paul Do you have a way to reproduce this reliably (i.e. it always happens when you open that specific routine)? What OS are you on? On my M1 Mac I have no issues opening a dense ~9300 line MAC routine.

@RalphGauer-Paul
Copy link

I'm on MS Windows 10 with 16 GiB RAM.
I'll see if I can create an example file...

@RalphGauer-Paul
Copy link

RalphGauer-Paul commented Oct 31, 2024

I still don't have an expample file yet,
but another symptom is that after several automatic restarts something is failing completely and restarting vscode is the only way of remedy:

[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Stopping server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 1:26:09 PM] Delivering pending changes failed
TypeError: this.task is not a function
at c:\Users\RAG\.vscode\extensions\intersystems.language-server-2.6.3-win32-x64\client\out\extension.js:2:289647

@isc-bsaviano
Copy link
Contributor

@RalphGauer-Paul VS Code will only attempt to restart the language server process 5 times. After that it gives up, and you have to restart VS Code to try again. That behavior is not specific to this crash. If you're running out of memory then there must be a memory leak of some sort. Without a reliable way to reproduce this its going to be hard to track down but I will try. Can you try downgrading like @xiaonuozi and let me know if 2.5.1 works for you? If so then that might help me identify a code change that caused this leak.

@RalphGauer-Paul
Copy link

RalphGauer-Paul commented Oct 31, 2024

Ok, I'll try that...
So far this seems to work.
Further tests will be possible after November 3rd.

@RalphGauer-Paul
Copy link

With version 2.5.1 I'm getting some errors, too, but no "out of memory":

[Error - 8:37:44 AM] Request textDocument/diagnostic failed.
Message: Request textDocument/diagnostic failed with message: Invalid regular expression: /^SL(0,.(mac|int|obj)$/: Unterminated group
Code: -32603
[Error - 8:37:44 AM] Document pull failed for text document isfs://lisa:emu/DAVSL1.mac
Message: Request textDocument/diagnostic failed with message: Invalid regular expression: /^SL(0,.(mac|int|obj)$/: Unterminated group
Code: -32603
c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2
(()=>{var webpack_modules={2117:(e,t,n)=>{e=n.nmd(e);try{process.dlopen(e,__dirname+n(6928).sep+n.p+"ec12b...
^

Error: General failure [80004005]
at t.parseDocument (c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:982)
at c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:218522
at Generator.next ()
at c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:216317
at new Promise ()
at r (c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:216062)
at c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:218344
at a.invoke (c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:815445)
at o.fire (c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:816210)
at c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\server\out\server.js:2:948614

Node.js v20.18.0
[Error - 12:04:27 PM] Server process exited with code 1.
[Info - 12:04:27 PM] Connection to server got closed. Server will restart.
true
[Error - 12:04:27 PM] Delivering pending changes failed
TypeError: this.task is not a function
at c:\Users\RAG.vscode\extensions\intersystems.language-server-2.5.1-win32-x64\client\out\extension.js:2:289647
[Error - 1:43:14 PM] Request textDocument/diagnostic failed.
Message: Request textDocument/diagnostic failed with message: Invalid regular expression: /^) = 7.(mac|int|obj)$/: Unmatched ')'
Code: -32603
[Error - 1:43:14 PM] Document pull failed for text document isfs://lisa:emu/DAVSL1.mac
Message: Request textDocument/diagnostic failed with message: Invalid regular expression: /^) = 7.(mac|int|obj)$/: Unmatched ')'
Code: -32603

@isc-bsaviano
Copy link
Contributor

@RalphGauer-Paul Thanks for checking this. Those messages are coming from a known bug that was fixed in a later version.

@isc-bsaviano isc-bsaviano self-assigned this Dec 2, 2024
@isc-bsaviano isc-bsaviano added the bug Something isn't working label Dec 2, 2024
@isc-bsaviano isc-bsaviano changed the title After using the plugin, the memory keeps increasing until this error occurs, and then it continues to grow Memory leak in parser module Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants