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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Languageserver crashes on long string (?) #313

Closed
hongooi73 opened this issue Jul 24, 2020 · 7 comments · Fixed by #314
Closed

Languageserver crashes on long string (?) #313

hongooi73 opened this issue Jul 24, 2020 · 7 comments · Fixed by #314

Comments

@hongooi73
Copy link

I just had this happen to me with VSCode. If you paste a long string into an R window, languageserver crashes:

string <- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
[2020-07-24 15:36:41.356] Error: Total path length must be less than PATH_MAX: 260
Call: path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))), 
    ext))
Stack trace:
1: path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))), 
    ext))
2: path(start, path[!is_abs])
3: path_norm(path(start, path[!is_abs]))
4: fs::path_abs(str_texts, rootPath)
5: document_link_reply(id, uri, self$workspace, document, rootPath)
6: handler(self, item$id, item$params)
7: parse_callback(self, uri, version, result)
8: private$callback(result)
9: task$check()
10: self$parse_task_manager$check_tasks()
11: self$process_events()

[2020-07-24 15:36:41.357] exiting

[Info  - 3:36:41 pm] Connection to server got closed. Server will restart.
[Error - 3:36:41 pm] Request textDocument/colorPresentation failed.
Error: Connection got disposed.
	at Object.dispose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\main.js:876:25)
	at Object.dispose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:71:35)
	at LanguageClient.handleConnectionClosed (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:2153:42)
	at LanguageClient.handleConnectionClosed (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\main.js:151:15)
	at closeHandler (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:2140:18)
	at CallbackList.invoke (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at closeHandler (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\main.js:226:26)
	at CallbackList.invoke (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at StreamMessageWriter.fireClose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\messageWriter.js:39:27)
	at Socket.<anonymous> (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\messageWriter.js:58:46)
	at Socket.emit (events.js:208:15)
	at TCP.<anonymous> (net.js:588:12)
[Error - 3:36:41 pm] Request textDocument/documentLink failed.
Error: Connection got disposed.
	at Object.dispose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\main.js:876:25)
	at Object.dispose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:71:35)
	at LanguageClient.handleConnectionClosed (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:2153:42)
	at LanguageClient.handleConnectionClosed (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\main.js:151:15)
	at closeHandler (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-languageclient\lib\client.js:2140:18)
	at CallbackList.invoke (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at closeHandler (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\main.js:226:26)
	at CallbackList.invoke (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\events.js:120:36)
	at StreamMessageWriter.fireClose (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\messageWriter.js:39:27)
	at Socket.<anonymous> (c:\Users\hongo\.vscode\extensions\reditorsupport.r-lsp-0.1.6\node_modules\vscode-jsonrpc\lib\messageWriter.js:58:46)
	at Socket.emit (events.js:208:15)
	at TCP.<anonymous> (net.js:588:12)
Language server exited with exit code 0

This first happened to me with an SSH public key, but the crash appears to trigger on any suitably long string. This may be a Windows-only problem, where the path has a relatively short maximum length, but it's unclear to me why languageserver is treating the string as a path in the first place.

System info:

  • languageserver 0.3.6
  • R LSP client 0.1.6
  • VSCode 1.47.2
  • Windows 10 2004
@randy3k
Copy link
Member

randy3k commented Jul 24, 2020

It seems we need to put a tryCatch somewhere to catch this exception.

@hongooi73
Copy link
Author

I guess the question is, why does languageserver treat the string as a path?

@randy3k
Copy link
Member

randy3k commented Jul 24, 2020

There is a feature called document links and we need to check if those strings are linked to actual files.

@renkun-ken
Copy link
Member

renkun-ken commented Jul 24, 2020

This seems to be Windows-specific.

Since fs::path_abs is a vectorized function, if a long string causes an error, a tryCatch will undermine all the results, then we need to de-vectorize it and use a tryCatch one by one.

I guess a simple fix is to just ignore all single-line string literals longer than 256 characters?

@kummerer94
Copy link

Hi! I am still experiencing this error. I am on the newest development version (and have also tested 0.3.7) and cannot get the language server to start for me. I am running Windows 10 Pro. The full error:

[2020-12-01 11:03:19.307] Error: Total path length must be less than PATH_MAX: 260
Call: path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))), 
    ext))
Stack trace:
1: path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))), 
    ext))
2: path(start, path[!is_abs])
3: path_norm(path(start, path[!is_abs]))
4: fs::path_abs(str_texts, rootPath)
5: document_link_reply(id, uri, self$workspace, document, rootPath)
6: handler(self, item$id, item$params)
7: parse_callback(self, uri, version, result)
8: private$callback(result)
9: task$check()
10: self$parse_task_manager$check_tasks()
11: self$process_events()

@albersonmiranda
Copy link

That explains a lot. I have a dashboard with entires paragraphs long strings and I'm struggling to get LS working. Will try break it to see if it works.

@renkun-ken
Copy link
Member

The languageserver ignores those single-line strings of more than 255 characters. Would you like to paste a string that triggers this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants