julia-vscode / LanguageServer.jl

An implementation of the Microsoft Language Server Protocol for the Julia language.
Other
355 stars 75 forks source link

Language server crashing #1233

Open staticfloat opened 10 months ago

staticfloat commented 10 months ago
┌ Error: Some Julia code in the VS Code extension crashed
└ @ Main ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/error_handler.jl:15
ERROR: BoundsError: attempt to access 0-element Vector{Any} at index [2]
Stacktrace:
  [1] getindex(A::Vector{Any}, i1::Int64)
    @ Base ./essentials.jl:13 [inlined]
  [2] resolve_getfield(x::CSTParser.EXPR, parent::SymbolServer.DataTypeStore, state::StaticLint.Toplevel{…})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/references.jl:273
  [3] resolve_getfield(x::CSTParser.EXPR, b::StaticLint.Binding, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/references.jl:226
  [4] resolve_getfield(x::CSTParser.EXPR, scope::StaticLint.Scope, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/references.jl:193
  [5] resolve_ref(x::CSTParser.EXPR, scope::StaticLint.Scope, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/references.jl:51
  [6] resolve_ref(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/references.jl:23
  [7] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:77
  [8] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
  [9] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [10] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
 [11] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [12] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
 [13] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [14] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
 [15] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [16] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
 [17] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [18] followinclude(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:285
 [19] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:78
 [20] traverse(x::CSTParser.EXPR, state::StaticLint.Toplevel{LanguageServer.Document})
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:225
 [21] (::StaticLint.Toplevel{LanguageServer.Document})(x::CSTParser.EXPR)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:92
 [22] semantic_pass(file::LanguageServer.Document, modified_expr::Nothing)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:174
 [23] semantic_pass(file::LanguageServer.Document)
    @ StaticLint ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/StaticLint/src/StaticLint.jl:170 [inlined]
 [24] relintserver(server::LanguageServerInstance)
    @ LanguageServer ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/LanguageServer/src/languageserverinstance.jl:426
 [25] run(server::LanguageServerInstance)
    @ LanguageServer ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/packages/LanguageServer/src/languageserverinstance.jl:407
 [26] top-level scope
    @ ~/.vscode/extensions/julialang.language-julia-1.48.1/scripts/languageserver/main.jl:104
 [27] include(mod::Module, _path::String)
    @ Base ./Base.jl:489
 [28] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:318
 [29] _start()
    @ Base ./client.jl:552
Some type information was truncated. Use `show(err)` to see complete types.
pfitzseb commented 10 months ago

Is this on Julia 1.10+? Is your code using any fancy new syntactical constructs?

staticfloat commented 10 months ago

I get this error using Julia v1.9 and latest master. The codebase is this repository.

fyzycyst commented 10 months ago

Note: May/may not relate to issue #1226

I'm on Win 10 Enterprise (22H2) / VSCode 1.81.1 w/ Julia extension 1.51.2... no other extensions loaded. I've gone so far as to uninstall the extension & VSCode & Julia, then do a clean reinstall of everything. Using Julia 1.9.3. When I load the LS extension, LS tries to start but crashes. I'll copy/paste the first bit of the output here and attach a text file with everything starting at "Please submit a bug report..."

The first bit is:

  Activating project at `c:\Users\p003227C\.vscode\extensions\julialang.language-julia-1.51.2\scripts\environments\languageserver\v1.9`
[ Info: Starting the Julia Language Server
ERROR: Endpoint is not running, the current state is closed.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] check_dead_endpoint!
   @ c:\Users\p003227C\.vscode\extensions\julialang.language-julia-1.51.2\scripts\packages\JSONRPC\src\core.jl:280 [inlined]
 [3] get_next_message(endpoint::JSONRPC.JSONRPCEndpoint{IOBuffer, Base.PipeEndpoint})
   @ JSONRPC c:\Users\p003227C\.vscode\extensions\julialang.language-julia-1.51.2\scripts\packages\JSONRPC\src\core.jl:212
 [4] macro expansion
   @ c:\Users\p003227C\.vscode\extensions\julialang.language-julia-1.51.2\scripts\packages\LanguageServer\src\languageserverinstance.jl:288 [inlined]
 [5] (::LanguageServer.var"#113#116"{LanguageServer.LanguageServerInstance})()
   @ LanguageServer .\task.jl:514
[ Info: Received new data from Julia Symbol Server.
[ Info: Shutting down server instance.
[ Info: Symbol server store is at 'c:\Users\p003227C\AppData\Roaming\Code\User\globalStorage\julialang.language-julia\symbolstorev5'.
[ Info: Starting LS at 1694033405
[ Info: Received new data from Julia Symbol Server.
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffd8c774a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffd8c774a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffd8c774a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffd8c774a36)
Internal error: stack overflow in type inference of string(CSTParser.ParseState, String, Any...).
This might be caused by recursion over very long tuples or argument lists.
Internal error: stack overflow in type inference of print_to_string(CSTParser.ParseState, Any...).
This might be caused by recursion over very long tuples or argument lists.
Internal error: stack overflow in type inference of string(CSTParser.ParseState, String, Any...).
This might be caused by recursion over very long tuples or argument lists.
Internal error: stack overflow in type inference of print_to_string(CSTParser.ParseState, Any...).
This might be caused by recursion over very long tuples or argument lists.

It goes on like that for quite a few lines. Again, the bug report output is attached.

Thanks. VSCode_LScrash_Output.txt

fyzycyst commented 9 months ago

By way of follow-up...

Now with VSCode 1.82.2 & Julia extension 1.52.2, upon loading I get:

  Activating project at `c:\Users\p003227C\.vscode\extensions\julialang.language-julia-1.52.2\scripts\environments\languageserver\v1.9`
[ Info: Starting the Julia Language Server
[ Info: Symbol server store is at 'c:\Users\p003227C\AppData\Roaming\Code\User\globalStorage\julialang.language-julia\symbolstorev5'.
[ Info: Starting LS at 1695848962
============== Startup timings ==============
       0.0 - LS startup started (0.0s since last event)
     0.016 - connection established (0.016s since last event)
     0.377 - (async) listening to client events (0.361s since last event)
     0.438 - (async) listening to symbol server events (0.061s since last event)
     0.443 - starting combined listener (0.0049999s since last event)
     0.475 - symbols received (0.032s since last event)
     0.476 - extended methods computed (0.00099993s since last event)
     0.476 - project deps computed (0.0s since last event)
     0.476 - env map computed (0.0s since last event)
     0.476 - initial lint done (0.0s since last event)
     0.555 - LSP/initialize (0.079s since last event)
     3.032 - LSP/initialized (2.477s since last event)
=============================================

Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffb71be4a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffb71be4a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
unknown function (ip: 00007ffb71be4a36)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()
RtlAllocateHeap at C:\windows\SYSTEM32\ntdll.dll (unknown line)
RtlAllocateHeap at C:\windows\SYSTEM32\ntdll.dll (unknown line)
malloc at C:\windows\System32\msvcrt.dll (unknown line)
operator new at /workspace/srcdir/gcc-12.1.0/libstdc++-v3/libsupc++\new_op.cc:50
.text$_ZN4llvm16ValueSymbolTable15createValueNameENS_9StringRefEPNS_5ValueE at C:\Users\p003227C\AppData\Local\Programs\Julia-1.9.3\bin\libLLVM-14jl.dll (unknown line)
.text$_ZN4llvm5Value11setNameImplERKNS_5TwineE at C:\Users\p003227C\AppData\Local\Programs\Julia-1.9.3\bin\libLLVM-14jl.dll (unknown line)
.text$_ZN4llvm5Value7setNameERKNS_5TwineE at C:\Users\p003227C\AppData\Local\Programs\Julia-1.9.3\bin\libLLVM-14jl.dll (unknown line)
Internal error: encountered unexpected error during compilation of getproperty:
StackOverflowError()

If I open a REPL in VSCode, I can execute code there, but VSCode itself is unable to execute code.

Thanks.

pfitzseb commented 9 months ago

It's likely that you have a invalid Julia file somewhere in your workspace (or one with very deeply nested expression trees). I think the next release of the extension might give you some hint as to which file is the issue.

https://discourse.julialang.org/t/language-server-broken/104071 is very similar.

fyzycyst commented 9 months ago

Thanks. I shall go hunting once more...

[So, I decided to drop a Daisycutter... uninstalled Julia and then completely deleted my .julia folder. Then I nuked the Julia extension. After reinstalling Julia and the extension, the Language Server now loads without a hitch. I think we can put this one to bed... suggest adding this as a form of tribal wisdom. There is such a section in the docs, right? ;) ]