LanguageServer.jl icon indicating copy to clipboard operation
LanguageServer.jl copied to clipboard

ArgumentError: embedded NULs are not allowed in C strings

Open davidanthoff opened this issue 4 years ago • 4 comments

From crash reporting.

More info in the link.

Stack trace:

ArgumentError:
   at unsafe_convert (c.jl216)
   at stat(::String) (stat.jl67)
   at isfile (stat.jl311)
   at process(::LanguageServer.JSONRPC.Request{Val{Symbol("textDocument/definition")},LanguageServer.TextDocumentPositionParams}, ::LanguageServerInstance) (.\scripts\languageserver\packages\LanguageServer\src\requests\features.jl116)
   at run(::LanguageServerInstance) (.\scripts\languageserver\packages\LanguageServer\src\languageserverinstance.jl233)
   at top-level scope (.\scripts\languageserver\main.jl28)
   at include (boot.jl328)
   at include_relative(::Module, ::String) (loading.jl1105)
   at include(::Module, ::String) (Base.jl31)
   at exec_options(::Base.JLOptions) (client.jl287)
   at _start() (client.jl460)

davidanthoff avatar Mar 13 '20 19:03 davidanthoff

Bump, we still get these, for example here. But note that the error in that latest crash report is in a different place.

What I don't understand is whether there is a NULL character in the input file, or whether the NULL char appears somewhere along the parsing line, i.e. is introduced in error? If it is in the input file, presumably that is not a valid Julia file then?

davidanthoff avatar May 03 '20 09:05 davidanthoff

What exactly is a NULL character in this sense? Either way would validating strings before calls to stat (e..g dirname, etc) be one way forward?

ZacLN avatar May 04 '20 12:05 ZacLN

Presumably just \u0? Maybe we should just bail on that if it occurs anywhere in code, presumably that is invalid? Maybe worth asking the core team how they handle that?

davidanthoff avatar May 06 '20 10:05 davidanthoff

I see a similar error in Neovim when a multiline snippet is returned as a completion candidate and inserted before it is expanded; in this case the newlines in the snippet are sent to Neovim as \0, which is then sent back to the server as a textDocument/didChange.

clason avatar Nov 19 '21 16:11 clason