withered-magic / starpls

An LSP implementation for Starlark, the configuration language used by Bazel and Buck2.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix panics due to bad offsets when calling rowan `token_at_offset`

withered-magic opened this issue · comments

Currently only see this behavior in Zed, but pretty often can get errors like

stderr: server: initializing state and starting event loop
stderr: server: determining workspace output_base
stderr: server: running "bazel info build-language"
stderr: thread '<unnamed>' panicked at external/crates__rowan-0.15.15/src/cursor.rs:751:9:
stderr: Bad offset: range 0..43 offset 47
stderr: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
stderr: Rayon: detected unexpected panic; aborting

Haven't seen this at all in VSCode, so I'm thinking it's maybe something Zed specific about the order in which it delivers textDocument/didChange notifications and positional requests like goto def

Actually I can get this to happen for rust-analyzer as well

stderr: thread 'Worker' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:786:13:
stderr: Bad range: node range 0..3, range 4..4
stderr: :
stderr: Bad range: node range 0..3, range 4..4

rust-analyzer catches these types of panics, so we should probably implement similar functionality (right now we only handle salsa::Cancelled)

@zaucy FYI, addressing this here in case you've seen this with Zed

I actually haven't ran into this! Or I just haven't noticed. Could be platform dependent? I'm mainly running on Windows right now.

Hmm, potentially, not familiar enough with how Zed does LSP to be sure though.. either way it should be fixed across platforms now!