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

Completion can crash the LSP in 1.9 (index out of bounds in Files) #2125

Closed
yannham opened this issue Dec 18, 2024 · 3 comments
Closed

Completion can crash the LSP in 1.9 (index out of bounds in Files) #2125

yannham opened this issue Dec 18, 2024 · 3 comments

Comments

@yannham
Copy link
Member

yannham commented Dec 18, 2024

Describe the bug

I get occasional crashes since Nickel 1.9 when using the LSP. I can't pinpoint the exact minimal conditions, but I have a reproduction below.

To Reproduce

For this to work (well, work meaning "crash NLS" here) you need to open a fresh file and type it. For some reason even copy/pasting the MRE in a new file doesn't trigger the bug, with or without the last .b.

let Schema = {
  field | String,
}
in

let value | Schema = {
  field = "bar",
}
in

value.b

The trailing .b will trigger completion and crash NLS. The log shows the following:

[2024-12-18T09:33:05Z DEBUG nls::server] handle completion
thread 'main' panicked at core/src/files.rs:238:12:
index out of bounds: the len is 10 but the index is 10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior

I expect this to not crash NLS.

Environment

  • OS name + version:
  • Version of the code: nickel-lang-lsp nls 1.9.0 (rev c58265a9-modified)

This is the version of the 1.9 release, just as installed by the release script (hence why the modified and the specific rev).

Additional context

As we shipped the new file implementation in 1.9, something must have gone wrong here. cc @jneem

@jneem
Copy link
Member

jneem commented Dec 18, 2024

Could it be this issue maybe?

@yannham
Copy link
Member Author

yannham commented Dec 18, 2024

Might be, I'll try out with latest master. If it is, I would be for a patch release if the fix can be extracted - I hit this several times since 1.9 release (it's surprising that this hasn't been noticed before, maybe because I open a lot of scratch files for test and repros, more than a standard user?)

@yannham
Copy link
Member Author

yannham commented Dec 19, 2024

Fixed in master an in 1.9.1

@yannham yannham closed this as completed Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants