smarty-vscode-support
smarty-vscode-support copied to clipboard
"Extension host terminated unexpectedly..." on code formatting
Describe the bug Sometimes, if some parts of code are present, whole extension host crashes on .tpl save. Debug console on vscode shows this when it happens:
localProcessExtensionHost.ts:294 Extension Host localProcessExtensionHost.ts:295 <--- Last few GCs ---> [18756:00007C8800000000] 6112 ms: Mark-sweep (reduce) 3801.0 (3830.1) -> 3800.8 (3814.4) MB, 34.8 / 0.0 ms (average mu = 0.936, current mu = 0.546) last resort GC in old space requested [18756:00007C8800000000] 6155 ms: Mark-sweep (reduce) 3800.8 (3814.4) -> 3800.8 (3814.4) MB, 43.1 / 0.0 ms (average mu = 0.825, current mu = 0.001) last resort GC in old space requested <--- JS stacktrace ---> FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: 00007FF6F799D696 node::Buffer::New+45638 2: 00007FF6F799D8A0 node::OnFatalError+464 3: 00007FF6FA3294F3 v8::CFunctionInfo::ArgumentInfo+803 4: 00007FF6FA32944C v8::CFunctionInfo::ArgumentInfo+636 5: 00007FF6FA3FDEE3 v8::JSHeapConsistency::CheckWrapper+65107 6: 00007FF6F8FD22FD v8::Locker::IsActive+129261 7: 00007FF6F8FBE45C v8::Locker::IsActive+47692 8: 00007FF6F8EAA5F1 uv_random+7384225 9: 00007FF6F70A363D v8::internal::OSROptimizedCodeCache::EvictMarkedCode+275581 10: 00007C88000F32FC abstractExtensionService.ts:644 Extension host (LocalProcess) terminated unexpectedly. Code: 134, Signal: null _onExtensionHostCrashed @ abstractExtensionService.ts:644 _onExtensionHostCrashed @ extensionService.ts:256 _onExtensionHostCrashOrExit @ abstractExtensionService.ts:636 (anonymous) @ abstractExtensionService.ts:626 invoke @ event.ts:569 fire @ event.ts:736 _onExtHostProcessExit @ localProcessExtensionHost.ts:581 (anonymous) @ localProcessExtensionHost.ts:311 invoke @ event.ts:569 fire @ event.ts:736 G @ ipc.ts:632 onResponse @ ipc.ts:711 onBuffer @ ipc.ts:697 (anonymous) @ ipc.ts:509 invoke @ event.ts:569 fire @ event.ts:736 K @ event.ts:382 emit @ events.js:315 onMessage @ electron/js2c/renderer_init.js:105 log.ts:313 ERR Extension host (LocalProcess) terminated unexpectedly. The following extensions were running: aaron-bond.better-comments, vscode.microsoft-authentication, vscode.github-authentication, vscode.git-base, aswinkumar863.smarty-template-support, vscode.debug-auto-launch, vscode.ipynb, christian-kohler.path-intellisense, vscode.git, vscode.github, vscode.emmet, vscode.merge-conflict, ms-vscode-remote.remote-wsl-recommender, ms-vscode-remote.remote-containers, ms-vscode-remote.remote-wsl, PKief.material-icon-theme notificationsAlerts.ts:42 Extension host terminated unexpectedly 3 times within the last 5 minutes. onDidChangeNotification @ notificationsAlerts.ts:42 (anonymous) @ notificationsAlerts.ts:28 invoke @ event.ts:569 fire @ event.ts:736 addNotification @ notifications.ts:206 notify @ notificationService.ts:137 prompt @ notificationService.ts:202 _onExtensionHostCrashed @ extensionService.ts:291 _onExtensionHostCrashOrExit @ abstractExtensionService.ts:636 (anonymous) @ abstractExtensionService.ts:626 invoke @ event.ts:569 fire @ event.ts:736 _onExtHostProcessExit @ localProcessExtensionHost.ts:581 (anonymous) @ localProcessExtensionHost.ts:311 invoke @ event.ts:569 fire @ event.ts:736 G @ ipc.ts:632 onResponse @ ipc.ts:711 onBuffer @ ipc.ts:697 (anonymous) @ ipc.ts:509 invoke @ event.ts:569 fire @ event.ts:736 K @ event.ts:382 emit @ events.js:315 onMessage @ electron/js2c/renderer_init.js:105 log.ts:307 WARN Canceled: Canceled at Object.b [as canceled] (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:8:1172) at vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1529:8375 at Array.forEach (
) at u.dispose (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1529:8323) at Mr.dispose (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1779:6155) at Ml.stopExtensionHosts (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3067:18906) at Ml._onExtensionHostCrashed (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3067:19820) at Ml._onExtensionHostCrashed (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3070:5387) at Ml._onExtensionHostCrashOrExit (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3067:19576) at vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3067:19335 at f.invoke (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:145) at c.fire (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:1856) at z._onExtHostProcessExit (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3069:31130) at vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3069:25868 at f.invoke (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:145) at c.fire (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:1856) at G (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:3413) at T.onResponse (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:4386) at T.onBuffer (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:4226) at vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:1817 at f.invoke (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:145) at c.fire (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:1856) at EventEmitter.K (vscode-file://vscode-app/c:/Users/Tomek/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:65:51039) at EventEmitter.emit (events.js:315:20) at Object.onMessage (electron/js2c/renderer_init.js:105:1177)
Tried to trace the bug in vscode but there's just a formatter called by the extension and nothing logs after that:
[exthost] [trace] [aswinkumar863.smarty-template-support] INVOKE provider 'j=>j.provideDocumentFormattingEdits(h.URI.revive(B),N,z)'
Extension host crashes after that and next logs show up when it's restarted.
To Reproduce Add this code to .tpl file and save/format:
<div {if $homeslider.slides|count > 1}data-slick='{ldelim}{strip}
"autoplay": true,
"slidesToShow": 1,
"autoplaySpeed":{$homeslider.speed}
{/strip}{rdelim}'{/if}>
<h1>test</h1>
</div>
Expected behavior For starters it shouldn't crash extension host, but rather show notification about the code it isn't able to format. Next it should format properly code like that.
Screenshots
Bug:

Expected (with {if} removed it seems to be working fine) - open in new window to see animation:

Context (please complete the following information):
- VSCode 1.65.2
- Extension: 1.10.0 (I checked also 1.9.0 and 1.8.0 but the result is the same)
Additional context Global VSCode setting:
{
"editor.formatOnSave": true,
}
I found that the issue is caused by the very rarely used {ldelim},{rdelim} function.
For the time being, you can try the straightforward approach as suggested below.
<div {if $homeslider.slides|count > 1}
data-slick='{[
'autoplay' => true,
'slidesToShow' => 1,
'autoplaySpeed' => $homeslider.speed
]|json_encode}'
{/if}>
<h1>test</h1>
</div>
Actually {ldelim}some code{rdelim} on its own is formatted properly (apart from indentations when multilines are involved or extra whitespace added before inlined {/if}). Extension host starts crashing when I add {strip}{/strip} to the mix.
Anyway thanks for the suggestion. Working on some old code and wanted to get rid of awful {literal}{{/literal}some code...{literal}}{/literal} patern. Your way is much better :)
I also have the error with "Extension host crash". Do you know approximately when an update could be expected?