microsoft / vscode

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

Occasional crash when resize with panel on the right #110392

Closed hsir closed 3 years ago

hsir commented 3 years ago

Issue Type: Bug

If you are under a large project (e.g. with several submodules inside), open a code file with over 1000 lines (e.g. a large markdown file), and then move the panel to the right side, vscode may crash when you resize the panel (by dragging the sash), especially at a high frequency. The output log suggests it may be terminated due to an 'out of memory' problem.

VS Code version: Code 1.51.0 (fcac248b077b55bae4ba5bab613fd6e9156c2f0c, 2020-11-05T18:14:40.758Z) OS version: Darwin x64 19.6.0

Screenshots ![scr3](https://user-images.githubusercontent.com/5260937/98815260-d17d2780-2461-11eb-9e03-3bc0ded2c512.png) ![scr1](https://user-images.githubusercontent.com/5260937/98814821-32583000-2461-11eb-97eb-ec40cbb13ff5.png) ![scr2](https://user-images.githubusercontent.com/5260937/98814829-384e1100-2461-11eb-9140-72708b77d673.png)
System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 3| |Memory (System)|32.00GB (8.01GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (...) Extension|Author (truncated)|Version ---|---|--- npm-intellisense|chr|1.3.1 path-intellisense|chr|2.3.0 bracket-pair-colorizer-2|Coe|0.2.0 (5 theme extensions excluded)
alexdima commented 3 years ago

@hsir Does it make a difference if the panel is showing a terminal or if the panel is showing the problems view for example? (I'm trying to determine if this might be a problem with resizing editors or a problem with resizing terminals).

Do you have any editor wrapping specific settings or any terminal specific settings in your settings.json ?

hsir commented 3 years ago
  1. It crashes regardless of active view showing on the panel (I tested Terminal & Problems & Output).
  2. The only option for wrapping is "editor.wordWrap": "on", no terminal specific settings.
  3. (One possible crash point: somewhere near _constructLines()).
  4. I found resize the panel with large size .md files opened is more likely to crash.

Following is all of my editor related settings in my settings.json:

settings.json ```json { "editor.fontFamily": "'iA Writer Mono S', 'SF Mono', STHeiti", "editor.tabSize": 2, "editor.fontLigatures": true, "editor.smoothScrolling": true, "editor.formatOnType": true, "editor.formatOnPaste": true, "editor.minimap.enabled": true, "editor.renderWhitespace": "none", "editor.renderControlCharacters": false, "editor.multiCursorModifier": "alt", "workbench.editor.highlightModifiedTabs": true, "editor.wordWrap": "on", "editor.lineHeight": 24, "editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "comment", "settings": { } } ] }, "editor.semanticHighlighting.enabled": true, "editor.columnSelection": false, "[javascript]": { "editor.defaultFormatter": "HookyQR.beautify" } } ```
roblourens commented 3 years ago

(One possible crash point: somewhere near _constructLines()).

What do you mean by that?

hsir commented 3 years ago

(One possible crash point: somewhere near _constructLines()).

What do you mean by that?

I initially thought it was a crash caused by the rendering of the code lines, so i set debug breakpoint on several possible crash locations of the code (debug using Code - OSS, the dev version of VSCode), and most of the time it was crashed occasionally inside or outside of the _constructLines() function call. I hope this can somehow provide some useful information about the crash.

alexdima commented 3 years ago

@hsir The wrapping logic is identical for markdown and plain text files. I have created a large text file (8MB, 20K lines) -- file.zip

I have created multiple heap snapshots and I resized a lot the file between them., but I cannot find any logical memory leak:

image

Since we have a markdown extension that might also compute things when resizing the markdown file, could you please try to see if renaming the .md file to .txt reproduces the issue for you or not.

hsir commented 3 years ago

@alexdima Yes, it did crash even if I rename it to .txt. And actually, I have created a demo, a simple folder containing only one .md file that could reproduce the crash on my machine, you may give it a try:

test-110392.zip

Just download the zip file, unzip it, and use VSCode to load the folder (make sure the opened window size is a bit smaller than the regular window size), open the README.md inside it, and then move the panel to the right side, then resize the panel frequently.

I also recorded a video about it, check this out (you may need to download and extract the video from the zip):

110392-crashvid.mov.zip

alexdima commented 3 years ago

I see the crash in the video and that is horrible and I'm sorry about that. But I still could not reproduce the crash on my machine:

TO_UPLOAD

The only fishy thing which I did see is that we have a listener memory leak somewhere with these steps:

@joaomoreno I'm not sure if this belongs to you, but I saw sash.ts in there, so perhaps you can kick start the leak investigation.

image

[be4] potential listener LEAK detected, having 351 listeners already. MOST frequent listener (177):
check @ event.ts:391
_event._event @ event.ts:562
registerDraggable @ dnd.ts:712
render @ compositeBarActions.ts:504
(anonymous) @ actionbar.ts:223
push @ actionbar.ts:223
(anonymous) @ compositeBar.ts:554
updateCompositeSwitcher @ compositeBar.ts:554
layout @ compositeBar.ts:293
layoutCompositeBar @ panelPart.ts:582
layout @ panelPart.ts:582
layout @ gridview.ts:757
layout @ splitview.ts:90
layoutViews @ splitview.ts:828
onSashChange @ splitview.ts:535
fire @ event.ts:584
(anonymous) @ linkedList.ts:127
fire @ event.ts:584
(anonymous) @ sash.ts:247
fire @ event.ts:584
o @ browser.ts:96
event.ts:453     at M.registerDraggable (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6754:438)
    at e.render (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6762:555)
    at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1108:934
    at Array.forEach (<anonymous>)
    at c.push (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1108:491)
    at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6788:392
    at Array.forEach (<anonymous>)
    at _.updateCompositeSwitcher (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6788:231)
    at _.layout (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6784:353)
    at e.layoutCompositeBar (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6931:508)
    at e.layout (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:6931:263)
    at v.layout (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:640:11)
    at f.layout (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:609:603)
    at S.layoutViews (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:621:864)
    at S.onSashChange (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:616:511)
    at c.fire (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:99:87)
    at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:94:636
    at c.fire (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:99:67)
    at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:530:515
    at c.fire (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:99:67)
    at o (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:104:945)
joaomoreno commented 3 years ago

There is indeed a leak here at the workbench layer. Moving to @sbatten. Maybe this leak results in the crash, but I doubt it.

image


I wasn't able to repro the crash at all. Handing it off to @deepak1556 as well to guide the user into providing more details.

deepak1556 commented 3 years ago

I was able to repro the crash on macOS based on the test case from , thanks @hsir !

Stack:

Symbolicating...
Operating system: Mac OS X
                  10.16.0 20B50
CPU: amd64
     family 6 model 158 stepping 10
     12 CPUs

GPU: UNKNOWN

Crash reason:  EXC_BREAKPOINT / EXC_I386_BPT
Crash address: 0x110c36678
Process uptime: 47 seconds

Thread 0 (crashed)
 0  Electron Framework!logging::LogMessage::~LogMessage() [logging.cc : 958 + 0x0]
    rax = 0x0000000000000000   rdx = 0x0000010000000100
    rcx = 0x000000011546d780   rbx = 0x00007ffee4f2da18
    rsi = 0x0000000000000000   rdi = 0x00000000ffffff00
    rbp = 0x00007ffee4f2df00   rsp = 0x00007ffee4f2d9d0
     r8 = 0x0000000000000100    r9 = 0x0000010100000100
    r10 = 0x0000000000000100   r11 = 0x0000000000000100
    r12 = 0x00007ffee4f2da18   r13 = 0x00007ffee4f2da30
    r14 = 0x00007ffee4f2df18   r15 = 0x00007ffee4f2df20
    rip = 0x0000000110c36678
    Found by: given as instruction pointer in context
 1  Electron Framework!base::internal::OnNoMemoryInternal(unsigned long) [memory.cc : 38 + 0x8]
    rbp = 0x00007ffee4f2e060   rsp = 0x00007ffee4f2df10
    rip = 0x0000000110c555c3
    Found by: previous frame's frame pointer
 2  Electron Framework!(anonymous namespace)::OnNoMemory(unsigned long) [oom.h : 22 + 0x7]
    rbp = 0x00007ffee4f2e070   rsp = 0x00007ffee4f2e070
    rip = 0x00000001127a6b80
    Found by: previous frame's frame pointer
 3  Electron Framework!blink::ReportOOMErrorInMainThread(char const*, bool) [v8_initializer.cc : 100 + 0x5]
    rbp = 0x00007ffee4f2e080   rsp = 0x00007ffee4f2e080
    rip = 0x00000001127a5c99
    Found by: previous frame's frame pointer
 4  Electron Framework!v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [api.cc : 514 + 0x8]
    rbp = 0x00007ffee4f2e0a0   rsp = 0x00007ffee4f2e090
    rip = 0x000000010fcbdb60
    Found by: previous frame's frame pointer
 5  Electron Framework!v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [api.cc : 475 + 0xf]
    rbp = 0x00007ffee4f32af0   rsp = 0x00007ffee4f2e0b0
    rip = 0x000000010fcbdb23
    Found by: previous frame's frame pointer
 6  Electron Framework!v8::internal::Heap::FatalProcessOutOfMemory(char const*) [heap.cc : 5646 + 0xa]
    rbp = 0x00007ffee4f32b00   rsp = 0x00007ffee4f32b00
    rip = 0x000000010fe580f5
    Found by: previous frame's frame pointer
 7  Electron Framework!v8::internal::FactoryBase<v8::internal::Factory>::NewFixedDoubleArray(int, v8::internal::AllocationType) [isolate.h : 782 + 0xf]
    rbp = 0x00007ffee4f32b30   rsp = 0x00007ffee4f32b10
    rip = 0x000000010fe2a418
    Found by: previous frame's frame pointer
 8  Electron Framework!v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedDoubleElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)4> >::GrowCapacity(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [elements.cc : 777 + 0xa]
    rbp = 0x00007ffee4f32b80   rsp = 0x00007ffee4f32b40
    rip = 0x000000010ffc0a74
    Found by: previous frame's frame pointer
 9  Electron Framework!v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [runtime-array.cc : 188 + 0x9]
    rbp = 0x00007ffee4f32bc0   rsp = 0x00007ffee4f32b90
    rip = 0x00000001101818fe
    Found by: previous frame's frame pointer
10  Electron Framework!Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit + 0x38
    rbp = 0x00007ffee4f32be0   rsp = 0x00007ffee4f32bd0
    rip = 0x000000011075e9d8
    Found by: previous frame's frame pointer
11  0x3c00219d4c
    rbp = 0x00007ffee4f32e88   rsp = 0x00007ffee4f32bf0
    rip = 0x0000003c00219d4c
    Found by: previous frame's frame pointer
12  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f32f70   rsp = 0x00007ffee4f32e98
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
13  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33048   rsp = 0x00007ffee4f32f80
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
14  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f330f0   rsp = 0x00007ffee4f33058
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
15  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f331c8   rsp = 0x00007ffee4f33100
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
16  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33240   rsp = 0x00007ffee4f331d8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
17  0x3c000bb1b8
    rbp = 0x00007ffee4f332a8   rsp = 0x00007ffee4f33250
    rip = 0x0000003c000bb1b8
    Found by: previous frame's frame pointer
18  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33310   rsp = 0x00007ffee4f332b8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
19  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33350   rsp = 0x00007ffee4f33320
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
20  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33398   rsp = 0x00007ffee4f33360
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
21  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f333f8   rsp = 0x00007ffee4f333a8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
22  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33458   rsp = 0x00007ffee4f33408
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
23  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f334a8   rsp = 0x00007ffee4f33468
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
24  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f334f8   rsp = 0x00007ffee4f334b8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
25  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33558   rsp = 0x00007ffee4f33508
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
26  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f335a8   rsp = 0x00007ffee4f33568
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
27  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33620   rsp = 0x00007ffee4f335b8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
28  0x3c002e404b
    rbp = 0x00007ffee4f33690   rsp = 0x00007ffee4f33630
    rip = 0x0000003c002e404b
    Found by: previous frame's frame pointer
29  0x3c00284bba
    rbp = 0x00007ffee4f33738   rsp = 0x00007ffee4f336a0
    rip = 0x0000003c00284bba
    Found by: previous frame's frame pointer
30  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f337a0   rsp = 0x00007ffee4f33748
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
31  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33860   rsp = 0x00007ffee4f337b0
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
32  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f338b8   rsp = 0x00007ffee4f33870
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
33  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33930   rsp = 0x00007ffee4f338c8
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
34  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33988   rsp = 0x00007ffee4f33940
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
35  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33a00   rsp = 0x00007ffee4f33998
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
36  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33a68   rsp = 0x00007ffee4f33a10
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
37  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33ae0   rsp = 0x00007ffee4f33a78
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
38  0x3c002e404b
    rbp = 0x00007ffee4f33b50   rsp = 0x00007ffee4f33af0
    rip = 0x0000003c002e404b
    Found by: previous frame's frame pointer
39  0x3c00299870
    rbp = 0x00007ffee4f33bf0   rsp = 0x00007ffee4f33b60
    rip = 0x0000003c00299870
    Found by: previous frame's frame pointer
40  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33d10   rsp = 0x00007ffee4f33c00
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
41  0x3c000bb14e
    rbp = 0x00007ffee4f33d78   rsp = 0x00007ffee4f33d20
    rip = 0x0000003c000bb14e
    Found by: previous frame's frame pointer
42  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33dd8   rsp = 0x00007ffee4f33d88
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
43  0x3c000bb1b8
    rbp = 0x00007ffee4f33e40   rsp = 0x00007ffee4f33de8
    rip = 0x0000003c000bb1b8
    Found by: previous frame's frame pointer
44  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33eb0   rsp = 0x00007ffee4f33e50
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
45  0x3c000bb1b8
    rbp = 0x00007ffee4f33f18   rsp = 0x00007ffee4f33ec0
    rip = 0x0000003c000bb1b8
    Found by: previous frame's frame pointer
46  Electron Framework!Builtins_InterpreterEntryTrampoline + 0xd5
    rbp = 0x00007ffee4f33f68   rsp = 0x00007ffee4f33f28
    rip = 0x00000001106f2275
    Found by: previous frame's frame pointer
47  Electron Framework!Builtins_JSEntryTrampoline + 0x5a
    rbp = 0x00007ffee4f33f98   rsp = 0x00007ffee4f33f78
    rip = 0x00000001106efdba
    Found by: previous frame's frame pointer
48  Electron Framework!Builtins_JSEntry + 0x78
    rbp = 0x00007ffee4f34000   rsp = 0x00007ffee4f33fa8
    rip = 0x00000001106efb98
    Found by: previous frame's frame pointer
49  Electron Framework!v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [simulator.h : 142 + 0x8]
    rbp = 0x00007ffee4f34150   rsp = 0x00007ffee4f34010
    rip = 0x000000010fdea21c
    Found by: previous frame's frame pointer
50  Electron Framework!v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [execution.cc : 461 + 0x8]
    rbp = 0x00007ffee4f341d0   rsp = 0x00007ffee4f34160
    rip = 0x000000010fde9666
    Found by: previous frame's frame pointer
51  Electron Framework!v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [api.cc : 4995 + 0x15]
    rbp = 0x00007ffee4f342f0   rsp = 0x00007ffee4f341e0
    rip = 0x000000010fcdb2e8
    Found by: previous frame's frame pointer
52  Electron Framework!blink::V8ScriptRunner::CallFunction(v8::Local<v8::Function>, blink::ExecutionContext*, v8::Local<v8::Value>, int, v8::Local<v8::Value>*, v8::Isolate*) [v8_script_runner.cc : 489 + 0x1c]
    rbp = 0x00007ffee4f34400   rsp = 0x00007ffee4f34300
    rip = 0x00000001127a9b86
    Found by: previous frame's frame pointer
53  Electron Framework!blink::V8EventListener::InvokeWithoutRunnabilityCheck(blink::bindings::V8ValueOrScriptWrappableAdapter, blink::Event*) [v8_event_listener.cc : 256 + 0x11]
    rbp = 0x00007ffee4f344b0   rsp = 0x00007ffee4f34410
    rip = 0x00000001128c7290
    Found by: previous frame's frame pointer
54  Electron Framework!blink::JSBasedEventListener::Invoke(blink::ExecutionContext*, blink::Event*) [js_based_event_listener.cc : 154 + 0x17]
    rbp = 0x00007ffee4f34560   rsp = 0x00007ffee4f344c0
    rip = 0x000000011276f776
    Found by: previous frame's frame pointer
55  Electron Framework!blink::EventTarget::FireEventListeners(blink::Event&, blink::EventTargetData*, blink::HeapVector<blink::RegisteredEventListener, 1u>&) [event_target.cc : 914 + 0x10]
    rbp = 0x00007ffee4f34690   rsp = 0x00007ffee4f34570
    rip = 0x0000000112ec9b5d
    Found by: previous frame's frame pointer
56  Electron Framework!blink::EventTarget::FireEventListeners(blink::Event&) [event_target.cc : 828 + 0x11]
    rbp = 0x00007ffee4f346e0   rsp = 0x00007ffee4f346a0
    rip = 0x0000000112ec91b6
    Found by: previous frame's frame pointer
57  Electron Framework!blink::WindowEventContext::HandleLocalEvents(blink::Event&) [window_event_context.cc : 60 + 0x8]
    rbp = 0x00007ffee4f34700   rsp = 0x00007ffee4f346f0
    rip = 0x0000000112ecc734
    Found by: previous frame's frame pointer
58  Electron Framework!blink::EventDispatcher::Dispatch() [event_dispatcher.cc : 207 + 0x8]
    rbp = 0x00007ffee4f34790   rsp = 0x00007ffee4f34710
    rip = 0x0000000112ebe635
    Found by: previous frame's frame pointer
59  Electron Framework!blink::MouseEvent::DispatchEvent(blink::EventDispatcher&) [mouse_event.cc : 433 + 0x5]
    rbp = 0x00007ffee4f34820   rsp = 0x00007ffee4f347a0
    rip = 0x0000000112fd5771
    Found by: previous frame's frame pointer
60  Electron Framework!blink::EventDispatcher::DispatchEvent(blink::Node&, blink::Event&) [event_dispatcher.cc : 63 + 0x10]
    rbp = 0x00007ffee4f34870   rsp = 0x00007ffee4f34830
    rip = 0x0000000112ebde0c
    Found by: previous frame's frame pointer
61  Electron Framework!blink::MouseEventManager::DispatchMouseEvent(blink::EventTarget*, WTF::AtomicString const&, blink::WebMouseEvent const&, WTF::String const&, blink::FloatPoint const*, blink::EventTarget*, bool, int const&, WTF::String const&) [mouse_event_manager.cc : 0 + 0xb]
    rbp = 0x00007ffee4f348e0   rsp = 0x00007ffee4f34880
    rip = 0x00000001132ad8ef
    Found by: previous frame's frame pointer
62  Electron Framework!blink::PointerEventManager::SendMousePointerEvent(blink::Element*, WTF::String const&, blink::WebInputEvent::Type, blink::WebMouseEvent const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&, bool) [pointer_event_manager.cc : 821 + 0x18]
    rbp = 0x00007ffee4f34b70   rsp = 0x00007ffee4f348f0
    rip = 0x00000001132b3800
    Found by: previous frame's frame pointer
63  Electron Framework!blink::EventHandler::HandleMouseMoveOrLeaveEvent(blink::WebMouseEvent const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&, blink::HitTestResult*, blink::HitTestLocation*) [event_handler.cc : 1517 + 0x1b]
    rbp = 0x00007ffee4f34e90   rsp = 0x00007ffee4f34b80
    rip = 0x00000001132a3ecf
    Found by: previous frame's frame pointer
64  Electron Framework!blink::EventHandler::HandleMouseMoveEvent(blink::WebMouseEvent const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&, WTF::Vector<blink::WebMouseEvent, 0u, WTF::PartitionAllocator> const&) [event_handler.cc : 916 + 0x18]
    rbp = 0x00007ffee4f34fa0   rsp = 0x00007ffee4f34ea0
    rip = 0x00000001132a3591
    Found by: previous frame's frame pointer
65  Electron Framework!blink::PageWidgetEventHandler::HandleMouseMove(blink::LocalFrame&, blink::WebMouseEvent const&, blink::WebVector<blink::WebInputEvent const*> const&, blink::WebVector<blink::WebInputEvent const*> const&) [page_widget_delegate.cc : 220 + 0x15]
    rbp = 0x00007ffee4f35070   rsp = 0x00007ffee4f34fb0
    rip = 0x00000001135fba08
    Found by: previous frame's frame pointer
66  Electron Framework!blink::PageWidgetDelegate::HandleInputEvent(blink::PageWidgetEventHandler&, blink::WebCoalescedInputEvent const&, blink::LocalFrame*) [page_widget_delegate.cc : 126 + 0x18]
    rbp = 0x00007ffee4f35200   rsp = 0x00007ffee4f35080
    rip = 0x00000001135fb83f
    Found by: previous frame's frame pointer
67  Electron Framework!blink::WebViewImpl::HandleInputEvent(blink::WebCoalescedInputEvent const&) [web_view_impl.cc : 1815 + 0xb]
    rbp = 0x00007ffee4f35290   rsp = 0x00007ffee4f35210
    rip = 0x0000000113014daf
    Found by: previous frame's frame pointer
68  Electron Framework!content::RenderWidgetInputHandler::HandleInputEvent(blink::WebCoalescedInputEvent const&, ui::LatencyInfo const&, base::OnceCallback<void (content::InputEventAckState, ui::LatencyInfo const&, std::__1::unique_ptr<ui::DidOverscrollParams, std::__1::default_delete<ui::DidOverscrollParams> >, base::Optional<cc::TouchAction>)>) [render_widget_input_handler.cc : 453 + 0x6]
    rbp = 0x00007ffee4f354c0   rsp = 0x00007ffee4f352a0
    rip = 0x0000000114036417
    Found by: previous frame's frame pointer
69  Electron Framework!non-virtual thunk to content::RenderWidget::HandleInputEvent(blink::WebCoalescedInputEvent const&, ui::LatencyInfo const&, base::OnceCallback<void (content::InputEventAckState, ui::LatencyInfo const&, std::__1::unique_ptr<ui::DidOverscrollParams, std::__1::default_delete<ui::DidOverscrollParams> >, base::Optional<cc::TouchAction>)>) [render_widget.cc : 1078 + 0xd]
    rbp = 0x00007ffee4f354e0   rsp = 0x00007ffee4f354d0
    rip = 0x00000001140b3cc8
    Found by: previous frame's frame pointer
70  Electron Framework!content::QueuedWebInputEvent::Dispatch(content::MainThreadEventQueue*) [main_thread_event_queue.cc : 616 + 0x16]
    rbp = 0x00007ffee4f35590   rsp = 0x00007ffee4f354f0
    rip = 0x0000000114034366
    Found by: previous frame's frame pointer
71  Electron Framework!content::MainThreadEventQueue::DispatchRafAlignedInput(base::TimeTicks) [main_thread_event_queue.cc : 505 + 0xc]
    rbp = 0x00007ffee4f355f0   rsp = 0x00007ffee4f355a0
    rip = 0x0000000114033ecc
    Found by: previous frame's frame pointer
72  Electron Framework!blink::WebFrameWidgetBase::DispatchRafAlignedInput(base::TimeTicks) [web_frame_widget_base.cc : 618 + 0xc]
    rbp = 0x00007ffee4f35620   rsp = 0x00007ffee4f35600
    rip = 0x00000001130f630d
    Found by: previous frame's frame pointer
73  Electron Framework!blink::WidgetBase::BeginMainFrame(base::TimeTicks) [widget_base.cc : 69 + 0x5]
    rbp = 0x00007ffee4f35640   rsp = 0x00007ffee4f35630
    rip = 0x0000000112bd7a16
    Found by: previous frame's frame pointer
74  Electron Framework!cc::ProxyMain::BeginMainFrame(std::__1::unique_ptr<cc::BeginMainFrameAndCommitState, std::__1::default_delete<cc::BeginMainFrameAndCommitState> >) [proxy_main.cc : 232 + 0x5]
    rbp = 0x00007ffee4f35730   rsp = 0x00007ffee4f35650
    rip = 0x0000000111bfc4c8
    Found by: previous frame's frame pointer
75  Electron Framework!base::internal::Invoker<base::internal::BindState<void (cc::ProxyMain::*)(std::__1::unique_ptr<cc::BeginMainFrameAndCommitState, std::__1::default_delete<cc::BeginMainFrameAndCommitState> >), base::WeakPtr<cc::ProxyMain>, std::__1::unique_ptr<cc::BeginMainFrameAndCommitState, std::__1::default_delete<cc::BeginMainFrameAndCommitState> > >, void ()>::RunOnce(base::internal::BindStateBase*) [bind_internal.h : 489 + 0x3]
    rbp = 0x00007ffee4f35770   rsp = 0x00007ffee4f35740
    rip = 0x0000000111bfb8bd
    Found by: previous frame's frame pointer
76  Electron Framework!base::TaskAnnotator::RunTask(char const*, base::PendingTask*) [callback.h : 98 + 0x3]
    rbp = 0x00007ffee4f35820   rsp = 0x00007ffee4f35780
    rip = 0x0000000110c70c0f
    Found by: previous frame's frame pointer
77  Electron Framework!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow*, bool*) [thread_controller_with_message_pump_impl.cc : 324 + 0xf]
    rbp = 0x00007ffee4f358f0   rsp = 0x00007ffee4f35830
    rip = 0x0000000110c80dea
    Found by: previous frame's frame pointer
78  Electron Framework!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() [thread_controller_with_message_pump_impl.cc : 248 + 0xb]
    rbp = 0x00007ffee4f35940   rsp = 0x00007ffee4f35900
    rip = 0x0000000110c80b79
    Found by: previous frame's frame pointer
79  Electron Framework!invocation function for block in base::MessagePumpCFRunLoopBase::RunWorkSource(void*) [message_pump_mac.mm : 499 + 0x6]
    rbp = 0x00007ffee4f35960   rsp = 0x00007ffee4f35950
    rip = 0x0000000110cd1601
    Found by: previous frame's frame pointer
80  Electron Framework!base::mac::CallWithEHFrame(void () block_pointer) + 0xa
    rbp = 0x00007ffee4f35970   rsp = 0x00007ffee4f35970
    rip = 0x0000000110cccd9a
    Found by: previous frame's frame pointer
81  Electron Framework!base::MessagePumpCFRunLoopBase::RunWorkSource(void*) [message_pump_mac.mm : 475 + 0x5]
    rbp = 0x00007ffee4f359b0   rsp = 0x00007ffee4f35980
    rip = 0x0000000110cd0ecf
    Found by: previous frame's frame pointer
82  CoreFoundation!__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 0x11
    rbp = 0x00007ffee4f359c0   rsp = 0x00007ffee4f359c0
    rip = 0x00007fff2041f9fc
    Found by: previous frame's frame pointer
83  CoreFoundation!__CFRunLoopDoSource0 + 0xb4
    rbp = 0x00007ffee4f359f0   rsp = 0x00007ffee4f359d0
    rip = 0x00007fff2041f964
    Found by: previous frame's frame pointer
84  CoreFoundation!__CFRunLoopDoSources0 + 0xf8
    rbp = 0x00007ffee4f35a60   rsp = 0x00007ffee4f35a00
    rip = 0x00007fff2041f6df
    Found by: previous frame's frame pointer
85  CoreFoundation!__CFRunLoopRun + 0x37a
    rbp = 0x00007ffee4f367a0   rsp = 0x00007ffee4f35a70
    rip = 0x00007fff2041e111
    Found by: previous frame's frame pointer
86  CoreFoundation!CFRunLoopRunSpecific + 0x233
    rbp = 0x00007ffee4f36840   rsp = 0x00007ffee4f367b0
    rip = 0x00007fff2041d6be
    Found by: previous frame's frame pointer
87  Foundation!-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 0xd4
    rbp = 0x00007ffee4f36880   rsp = 0x00007ffee4f36850
    rip = 0x00007fff211a7fa1
    Found by: previous frame's frame pointer
88  Electron Framework!base::MessagePumpNSRunLoop::DoRun(base::MessagePump::Delegate*) [message_pump_mac.mm : 745 + 0x10]
    rbp = 0x00007ffee4f368c0   rsp = 0x00007ffee4f36890
    rip = 0x0000000110cd1b21
    Found by: previous frame's frame pointer
89  Electron Framework!base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*) [message_pump_mac.mm : 190 + 0xc]
    rbp = 0x00007ffee4f36900   rsp = 0x00007ffee4f368d0
    rip = 0x0000000110cd0882
    Found by: previous frame's frame pointer
90  Electron Framework!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) [thread_controller_with_message_pump_impl.cc : 429 + 0x6]
    rbp = 0x00007ffee4f36930   rsp = 0x00007ffee4f36910
    rip = 0x0000000110c81373
    Found by: previous frame's frame pointer
91  Electron Framework!base::RunLoop::Run() [run_loop.cc : 124 + 0x13]
    rbp = 0x00007ffee4f369c0   rsp = 0x00007ffee4f36940
    rip = 0x0000000110c59153
    Found by: previous frame's frame pointer
92  Electron Framework!content::RendererMain(content::MainFunctionParams const&) [renderer_main.cc : 226 + 0x5]
    rbp = 0x00007ffee4f36a80   rsp = 0x00007ffee4f369d0
    rip = 0x00000001140bf9c4
    Found by: previous frame's frame pointer
93  Electron Framework!content::ContentMainRunnerImpl::Run(bool) [content_main_runner_impl.cc : 882 + 0x5]
    rbp = 0x00007ffee4f36af0   rsp = 0x00007ffee4f36a90
    rip = 0x000000010f3be679
    Found by: previous frame's frame pointer
94  Electron Framework!service_manager::Main(service_manager::MainParams const&) [main.cc : 454 + 0x9]
    rbp = 0x00007ffee4f36e40   rsp = 0x00007ffee4f36b00
    rip = 0x000000011240fd78
    Found by: previous frame's frame pointer
95  Electron Framework!content::ContentMain(content::ContentMainParams const&) [content_main.cc : 19 + 0x8]
    rbp = 0x00007ffee4f36ed0   rsp = 0x00007ffee4f36e50
    rip = 0x000000010f3bdd54
    Found by: previous frame's frame pointer
96  Electron Framework!ElectronMain [electron_library_main.mm : 31 + 0x5]
    rbp = 0x00007ffee4f36f60   rsp = 0x00007ffee4f36ee0
    rip = 0x000000010e73b7d4
    Found by: previous frame's frame pointer
97  Code - Insiders Helper (Renderer)!main [electron_main.cc : 287 + 0xb]
    rbp = 0x00007ffee4f37030   rsp = 0x00007ffee4f36f70
    rip = 0x000000010acc98a5
    Found by: previous frame's frame pointer
98  libdyld.dylib!start + 0x1
    rbp = 0x00007ffee4f37048   rsp = 0x00007ffee4f37040
    rip = 0x00007fff20342631
    Found by: previous frame's frame pointer
99  libdyld.dylib!start + 0x1
    rbp = 0x00007ffee4f37048   rsp = 0x00007ffee4f37048
    rip = 0x00007fff20342631
    Found by: stack scanning
deepak1556 commented 3 years ago

It is indeed crashing due to OOM when invoking event listeners, which would align with https://github.com/microsoft/vscode/issues/110392#issuecomment-737757619

deepak1556 commented 3 years ago

I can still repro the OOM failure on latest master after @sbatten fix. Investigating further to see if we can get a hint to the JS executed from process sample.

deepak1556 commented 3 years ago

Based on the stack, root of the crash is that some event listener on mousemove is resizing an array beyond what v8 can provide and hence leading to OOM.

(lldb) frame select 10
frame #10: 0x00000001041b9c49 Electron Framework`v8::internal::FactoryBase<v8::internal::Factory>::NewFixedDoubleArray(this=0x00000015000098f0, length=75209227, allocation=<unavailable>) at factory-base.cc:118 [opt]
(lldb) p length
(int) $3 = 75209227 -> size of array is > 512MB

Connecting to a debugger also gives the JS stacktrace, but had to make a custom electron build with https://chromium-review.googlesource.com/c/v8/v8/+/1967377

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x1172ac658]
Security context: 0x003f08265ff9 <String[39]: #file://E3540C45D26E9AFC7116B0EF08DB122F>
    1: createLineBreaksFromPreviousLineBreaks(aka createLineBreaksFromPreviousLineBreaks) [0x3f0e75468d] [file:///Users/demohan/github/vscode/out/vs/editor/common/viewModel/monospaceLineBreaksComputer.js:~83] [pc=0x3f001c6c49](this=0x003f080423b1 <undefined>,0x003f0e526849 <CharacterClassifier map = 0x3f0c0c6f35>,0x00...

So createLineBreaksFromPreviousLineBreaks is leading the OOM crash, couldn't get more deeper trace here. But I think we can now narrow down the issue with some logs inside this function and see where the array size grows. /cc @alexdima

deepak1556 commented 3 years ago

Okay I was able to narrow down the source, the array size increase happens because of ever increasing breakingOffsetsCount

https://github.com/microsoft/vscode/blob/de2c02eb5046b429cd384595fbb61820f0384aa5/src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts#L310

It happens when prevIndex becomes 0

https://github.com/microsoft/vscode/blob/de2c02eb5046b429cd384595fbb61820f0384aa5/src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts#L142

and never gets incremented because distance >= bestDistance tends to be false

https://github.com/microsoft/vscode/blob/de2c02eb5046b429cd384595fbb61820f0384aa5/src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts#L320

deepak1556 commented 3 years ago

Based on the above repro becomes simpler, @alexdima trying to bring the sash as close to the left edge and then drag back so the above condition is met.

alexdima commented 3 years ago

:+1: Thank you for the extra details, I was able to repro it and extract a test case.

github-actions[bot] commented 3 years ago

This bug has been fixed in to the latest release of VS Code Insiders!

@hsir, you can help us out by confirming things are working as expected in the latest Insiders release. If things look good, please leave a comment with the text /verified to let us know. If not, please ensure you're on version 7b0cfdd04ad530a9c8d782c618afd79290be3d64 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!