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

Segfault on incorrect coordinates #395

Closed
krassowski opened this issue Mar 20, 2021 · 2 comments · Fixed by #407
Closed

Segfault on incorrect coordinates #395

krassowski opened this issue Mar 20, 2021 · 2 comments · Fixed by #407

Comments

@krassowski
Copy link
Contributor

krassowski commented Mar 20, 2021

Not really a huge issues, just something nice to have:

Sometimes incorrect coordinates (row/col) can lead to segmentation fault (noticed during work on an lsp client). This is unlikely to happen in well-behaved clients, but it might happen, so ideally the off by one errors in indexing would be caught rather than leading to a segfault.

 *** caught segfault ***
address 0x80000000, cause 'memory not mapped'

Traceback:
 1: find_unbalanced_bracket(self$content, row, col - 1)
 2: document$detect_call(point)
 3: completion_reply(id, uri, self$workspace, document, point, self$ClientCapabilities$textDocument$completion)
 4: self$deliver(completion_reply(id, uri, self$workspace, document,     point, self$ClientCapabilities$textDocument$completion))
 5: dispatch(self, id, params)
 6: eval(expr, env)
 7: eval(expr, env)
 8: withCallingHandlers(eval(expr, env), error = capture_calls)
 9: doTryCatch(return(expr), name, parentenv, handler)
10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
11: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch(withCallingHandlers(eval(expr, env), error = capture_calls),     ...)
13: tryCatchStack({    dispatch <- self$request_handlers[[method]]    dispatch(self, id, params)}, error = function(e) {    logger$info("internal error:", e)    self$deliver(ResponseErrorMessage$new(id, "InternalError",         to_string(e)))})
14: self$handle_request(payload)
15: self$handle_raw(data)
16: eval(expr, env)
17: eval(expr, env)
18: withCallingHandlers(eval(expr, env), error = capture_calls)
19: doTryCatch(return(expr), name, parentenv, handler)
20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
21: tryCatchList(expr, classes, parentenv, handlers)
22: tryCatch(withCallingHandlers(eval(expr, env), error = capture_calls),     ...)
23: tryCatchStack({    if (isTRUE(self$exit_flag)) {        logger$info("exiting")        break    }    self$process_events()    data <- self$fetch(blocking = FALSE)    if (is.null(data)) {        Sys.sleep(0.1)        next    }    self$handle_raw(data)}, error = function(e) e)
24: langserver$run()
25: languageserver::run()

I think this is due to a complete request with col = 6 instead of col = 5 (edited):

{
  "jsonrpc": "2.0",
  "id": 11,
  "method": "textDocument/completion",
   "params": {
      "textDocument": {"uri":"file:///.../file.R"},
      "position": {"line": 0,"character": 6},
      "context": {"triggerKind": 1,"triggerCharacter": "r"}
  }
}
@randy3k
Copy link
Member

randy3k commented Mar 31, 2021

Would you mind telling me the content of file.R? I cannot reproduce it on my end.

@randy3k
Copy link
Member

randy3k commented Mar 31, 2021

Wait, the offending argument is not col, it is actually line.

randy3k added a commit that referenced this issue Mar 31, 2021
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.

2 participants