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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: Out of memory language server crash #699

Open
steveoh opened this issue Nov 15, 2023 · 4 comments
Open

馃悰 BUG: Out of memory language server crash #699

steveoh opened this issue Nov 15, 2023 · 4 comments
Labels
needs investigation The cause of the issue is unknown and a deeper investigation is needed to fix it

Comments

@steveoh
Copy link

steveoh commented Nov 15, 2023

Describe the Bug

Opening my monorepo that contains an astro website the language server crashes.

runtime: out of memory: cannot allocate 4194304-byte block (2138931200 in use)
fatal error: out of memory

goroutine 6 [running]:
runtime.throw({0x3e407, 0xd})
	runtime/panic.go:1047 +0x3 fp=0x6f0130 sp=0x6f0108 pc=0x12260003
runtime.(*mcache).allocLarge(0x220108, 0x113106, 0x1)
	runtime/mcache.go:235 +0x37 fp=0x6f0180 sp=0x6f0130 pc=0x10e70037
runtime.mallocgc(0x113106, 0x0, 0x0)
	runtime/malloc.go:1029 +0x8b fp=0x6f0200 sp=0x6f0180 pc=0x109f008b
runtime.rawstring(0x113106)
	runtime/string.go:273 +0x2 fp=0x6f0228 sp=0x6f0200 pc=0x13130002
runtime.rawstringtmp(0x0, 0x113106)
	runtime/string.go:135 +0x7 fp=0x6f0260 sp=0x6f0228 pc=0x130e0007
runtime.concatstrings(0x0, {0x6f0328, 0x2, 0x2})
	runtime/string.go:51 +0x13 fp=0x6f02f8 sp=0x6f0260 pc=0x13080013
runtime.concatstring2(0x0, {0xff628000, 0x112e0f}, {0x317c9500, 0x2f7})
	runtime/string.go:60 +0x2 fp=0x6f0350 sp=0x6f02f8 pc=0x13090002
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3a511, 0x7}, {0x4a204, 0x3}, {0x0, 0x0}, {0x11cb180, 0x4, 0x4}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7d fp=0x6f0640 sp=0x6f0350 pc=0x18d4007d
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3a511, 0x7}, {0x49c61, 0x3}, {0x0, 0x0}, {0x11d2680, 0x1, 0x1}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f0930 sp=0x6f0640 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3a511, 0x7}, {0x49c61, 0x3}, {0x0, 0x0}, {0x119cc30, 0x1, 0x1}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f0c20 sp=0x6f0930 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3a511, 0x7}, {0x49c61, 0x3}, {0x0, 0x0}, {0x119ca90, 0x1, 0x1}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f0f10 sp=0x6f0c20 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3a511, 0x7}, {0x4a05e, 0x7}, {0x0, 0x0}, {0x119c8f0, 0x1, 0x1}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f1200 sp=0x6f0f10 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x3bc93, 0x9}, {0x698022, 0xa}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f14f0 sp=0x6f1200 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.ASTNode.String({{0x38301, 0x4}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, ...}, ...})
	github.com/withastro/compiler/internal/printer/print-to-json.go:87 +0x7c fp=0x6f17e0 sp=0x6f14f0 pc=0x18d4007c
github.com/withastro/compiler/internal/printer.PrintToJSON({0x103e000, 0x3a439}, 0x4a4280, {{0x39edc, 0x7}, 0x1})
	github.com/withastro/compiler/internal/printer/print-to-json.go:117 +0xe fp=0x6f1c38 sp=0x6f17e0 pc=0x18d5000e
main.Parse.func1({{}, 0x7ff800010000000d, 0x699f68}, {0x42c0c0, 0x2, 0x2})
	./astro-wasm.go:225 +0x2b fp=0x6f1ec0 sp=0x6f1c38 pc=0x190d002b
syscall/js.handleEvent()
	syscall/js/func.go:94 +0x26 fp=0x6f1f90 sp=0x6f1ec0 pc=0x15690026
runtime.handleEvent()
	runtime/lock_js.go:251 +0x14 fp=0x6f1fe0 sp=0x6f1f90 pc=0x10960014
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x6f1fe8 sp=0x6f1fe0 pc=0x13ef0001
created by runtime.beforeIdle
	runtime/lock_js.go:207 +0x1a

goroutine 1 [chan receive]:
runtime.gopark(0x4a778, 0x4320b8, 0xe, 0x17, 0x2)
	runtime/proc.go:363 +0x27 fp=0x438d38 sp=0x438d10 pc=0x124d0027
runtime.chanrecv(0x432060, 0x0, 0x1)
	runtime/chan.go:583 +0x7c fp=0x438dc0 sp=0x438d38 pc=0x1062007c
runtime.chanrecv1(0x432060, 0x0)
	runtime/chan.go:442 +0x2 fp=0x438de8 sp=0x438dc0 pc=0x10610002
main.main()
	./astro-wasm.go:30 +0xd fp=0x438f80 sp=0x438de8 pc=0x1906000d
runtime.main()
	runtime/proc.go:250 +0x35 fp=0x438fe0 sp=0x438f80 pc=0x12480035
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x438fe8 sp=0x438fe0 pc=0x13ef0001

goroutine 2 [force gc (idle)]:
runtime.gopark(0x4a8f0, 0x1f0170, 0x11, 0x14, 0x1)
	runtime/proc.go:363 +0x27 fp=0x424fb8 sp=0x424f90 pc=0x124d0027
runtime.goparkunlock(...)
	runtime/proc.go:369
runtime.forcegchelper()
	runtime/proc.go:302 +0x17 fp=0x424fe0 sp=0x424fb8 pc=0x124b0017
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x424fe8 sp=0x424fe0 pc=0x13ef0001
created by runtime.init.5
	runtime/proc.go:290 +0x2

goroutine 3 [runnable]:
runtime.gopark(0x4a8f0, 0x1f0460, 0xc, 0x14, 0x1)
	runtime/proc.go:363 +0x27 fp=0x4257a8 sp=0x425780 pc=0x124d0027
runtime.goparkunlock(...)
	runtime/proc.go:369
runtime.bgsweep(0x42a000)
	runtime/mgcsweep.go:297 +0x20 fp=0x4257d0 sp=0x4257a8 pc=0x117a0020
runtime.gcenable.func1()
	runtime/mgc.go:178 +0x2 fp=0x4257e0 sp=0x4257d0 pc=0x11000002
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x4257e8 sp=0x4257e0 pc=0x13ef0001
created by runtime.gcenable
	runtime/mgc.go:178 +0x8

goroutine 4 [runnable]:
runtime.gopark(0x4a8f0, 0x1f0540, 0x13, 0x13, 0x2)
	runtime/proc.go:363 +0x27 fp=0x425f30 sp=0x425f08 pc=0x124d0027
runtime.goparkunlock(...)
	runtime/proc.go:369
runtime.(*scavengerState).sleep(0x1f0540, 0x40d8c00000000000)
	runtime/mgcscavenge.go:468 +0x2a fp=0x425fa8 sp=0x425f30 pc=0x1164002a
runtime.bgscavenge(0x42a000)
	runtime/mgcscavenge.go:626 +0xb fp=0x425fd0 sp=0x425fa8 pc=0x1167000b
runtime.gcenable.func2()
	runtime/mgc.go:179 +0x2 fp=0x425fe0 sp=0x425fd0 pc=0x10ff0002
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x425fe8 sp=0x425fe0 pc=0x13ef0001
created by runtime.gcenable
	runtime/mgc.go:179 +0xe

goroutine 5 [finalizer wait]:
runtime.gopark(0x4a8f0, 0x20d068, 0x10, 0x14, 0x1)
	runtime/proc.go:363 +0x27 fp=0x424738 sp=0x424710 pc=0x124d0027
runtime.goparkunlock(...)
	runtime/proc.go:369
runtime.runfinq()
	runtime/mfinal.go:180 +0x21 fp=0x4247e0 sp=0x424738 pc=0x10f70021
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x4247e8 sp=0x4247e0 pc=0x13ef0001
created by runtime.createfing
	runtime/mfinal.go:157 +0x5

goroutine 7 [GC worker (idle)]:
runtime.gopark(0x4a7c0, 0x4b9fa0, 0x18, 0x14, 0x0)
	runtime/proc.go:363 +0x27 fp=0x426758 sp=0x426730 pc=0x124d0027
runtime.gcBgMarkWorker()
	runtime/mgc.go:1235 +0x1f fp=0x4267e0 sp=0x426758 pc=0x1113001f
runtime.goexit()
	runtime/asm_wasm.s:401 +0x1 fp=0x4267e8 sp=0x4267e0 pc=0x13ef0001
created by runtime.gcBgMarkStartWorkers
	runtime/mgc.go:1159 +0x3
exit code: 2
/Users/sgourley/.vscode/extensions/astro-build.astro-vscode-2.5.2-darwin-x64/node_modules/@astrojs/compiler/dist/node/sync.cjs:1
"use strict";var P=Object.create;var y=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var O=(i,n)=>{for(var s in n)y(i,s,{get:n[s],enumerable:!0})},T=(i,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of A(n))!C.call(i,c)&&c!==s&&y(i,c,{get:()=>n[c],enumerable:!(r=I(n,c))||r.enumerable});return i};var x=(i,n,s)=>(s=i!=null?P(E(i)):{},T(n||!i||!i.__esModule?y(s,"default",{value:i,enumerable:!0}):s,i)),D=i=>T(y({},"__esModule",{value:!0}),i);var M={};O(M,{convertToTSX:()=>W,parse:()=>L,startRunningService:()=>R,transform:()=>N});module.exports=D(M);var k=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,w=k();var S=require("fs"),j=require("url");var v=x(require("crypto"),1),b=x(require("fs"),1),_=require("util");globalThis.fs||Object.defineProperty(globalThis,"fs",{value:b.default});globalThis.process||Object.defineProperties(globalThis,"process",{value:process});globalThis.crypto||Object.defineProperty(globalThis,"crypto",{value:v.default.webcrypto?v.default.webcrypto:{getRandomValues(i){return v.default.randomFillSync(i)}}});globalThis.performance||Object.defineProperty(globalThis,"performance",{value:{now(){let[i,n]=process.hrtime();return i*1e3+n/1e6}}});var U=new _.TextEncoder("utf-8"),V=new _.TextDecoder("utf-8");var d=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let n=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},s=e=>{let t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},r=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let o=this.mem.getUint32(e,!0);return this._values[o]},c=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,2146959360|m,!0),this.mem.setUint32(e,a,!0)},l=e=>{let t=s(e+0),o=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},g=e=>{let t=s(e+0),o=s(e+8),a=new Array(o);for(let m=0;m<o;m++)a[m]=r(t+m*8);return a},h=e=>{let t=s(e+0),o=s(e+8);return V.decode(new DataView(this._inst.exports.mem.buffer,t,o))},u=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;let t=s(e+8),o=s(e+16),a=this.mem.getInt32(e+24,!0);b.default.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,a))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,n(e+8,(u+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;let t=new Date().getTime();n(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,globalThis.crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){let o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,c(e+24,h(e+8))},"syscall/js.valueGet":e=>{e>>>=0;let t=Reflect.get(r(e+8),h(e+16));e=this._inst.exports.getsp()>>>0,c(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(r(e+8),h(e+16),r(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(r(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,c(e+24,Reflect.get(r(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(r(e+8),s(e+16),r(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{let t=r(e+8),o=Reflect.get(t,h(e+16)),a=g(e+32),m=Reflect.apply(o,t,a);e=this._inst.exports.getsp()>>>0,c(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,n(e+16,parseInt(r(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;let t=U.encode(String(r(e+8)));c(e+16,t),n(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;let t=r(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,r(e+8)instanceof r(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;let t=l(e+8),o=r(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;let t=r(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(n){if(!(n instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=n,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,r=u=>{let e=s,t=U.encode(u+"\0");return new Uint8Array(this.mem.buffer,s,t.length).set(t),s+=t.length,s%8!==0&&(s+=8-s%8),e},c=this.argv.length,l=[];this.argv.forEach(u=>{l.push(r(u))}),l.push(0),Object.keys(this.env).sort().forEach(u=>{l.push(r(`${u}=${this.env[u]}`))}),l.push(0);let h=s;l.forEach(u=>{this.mem.setUint32(s,u,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(c,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(n){let s=this;return function(){let r={id:n,this:this,args:arguments};return s._pendingEvent=r,s._resume(),r.result}}};function p(){return f||(f=R()),f}var f,N=(i,n)=>p().transform(i,n),L=(i,n)=>p().parse(i,n),W=(i,n)=>p().convertToTSX(i,n);function R(){let i=new d,n=F((0,j.fileURLToPath)(new URL("../astro.wasm",w)),i.importObject);i.run(n);let s=globalThis["@astrojs/compiler"];return{transform:(r,c)=>{try{return s.transform(r,c||{})}catch(l){throw f=void 0,l}},parse:(r,c)=>{try{let l=s.parse(r,c||{});return{...l,ast:JSON.parse(l.ast)}}catch(l){throw f=void 0,l}},convertToTSX:(r,c)=>{try{let l=s.convertToTSX(r,c||{});return{...l,map:JSON.parse(l.map)}}catch(l){throw f=void 0,l}}}}function F(i,n){le[Error - 10:20:37 AM] Server process exited with code 1.
[Info  - 10:20:37 AM] Connection to server got closed. Server will restart.
true
runtime: out of memory: cannot allocate 4194304-byte block (2117959680 in use)
fatal error: out of memory

Steps to Reproduce

  1. npm init astro using template startlight/tailwind
  2. ...
  3. ...
  4. ...
  5. Error! Describe what went wrong (and what was expected instead)...
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 15, 2023
@Princesseuh
Copy link
Member

Could you share the repository in question?

@Princesseuh Princesseuh added the needs repro Issue needs a reproduction label Nov 15, 2023
Copy link
Contributor

Hello @steveoh. Please provide a minimal reproduction using a GitHub repository or at least sharing the file where the issue happen. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Nov 15, 2023
@steveoh
Copy link
Author

steveoh commented Nov 15, 2023

Here's the actual repo and the astro project is explorer

https://github.com/agrc/api.mapserv.utah.gov/tree/development

I'm not sure there is an actual file, I just open any file in the templated project and the language server fails.

@Princesseuh Princesseuh removed the needs repro Issue needs a reproduction label Nov 15, 2023
@Princesseuh
Copy link
Member

Thank you! I'll take a look as soon as possible

@Princesseuh Princesseuh added the needs investigation The cause of the issue is unknown and a deeper investigation is needed to fix it label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation The cause of the issue is unknown and a deeper investigation is needed to fix it
Projects
None yet
Development

No branches or pull requests

2 participants