Skip to content

Kernel restarting due to an exception in completions (in core R) #702

@krassowski

Description

@krassowski

So that's hard to reproduce, but I'm getting this a lot in JupyterLab with LSP extension installed. The LSP extension can trigger completions after typing any character, so it may sometimes trigger in odd places and I think this leads to some edge case in completions handling; pretty often the kernel will die and restart with the following message in the console:

Error in suppressWarnings(gregexpr("[^\\.\\w:?$@[\\]]+", linebuffer, perl = TRUE))[[1L]] :
  subscript out of bounds
Calls: <Anonymous> ... handle_shell -> complete -> completions -> <Anonymous>
Execution halted
[I 2021-12-01 15:50:58.092 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
kernel 6940fbfd-10d1-4918-ada7-7028d880a2f3 restarted

It seems to come from this call:

IRkernel/R/completion.r

Lines 23 to 24 in d872064

c.info <- get('.guessTokenFromLine', utils_ns)(update = FALSE)
get('.guessTokenFromLine', utils_ns)()

To a core function which was not modified in the last 8 years:

https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/library/utils/R/completion.R#L286-L291

I wonder, is this off-by-one error on my side, or potentially something in IRKernel? In either case I thought it would be worth to record an issue here to ask if anyone saw something similar.

I wonder if this could be that sometimes completing on empty line triggers this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions