Stack Overflow fetching builtin rules
Hey!
I'm running starpls on one of my org's monorepos, and am having some issues. Shortly after I open VSCode, the bazel LSP seems to work fine -- I can command-click around to definitions like I'd expect. However, within a few seconds, I get a prompt saying the LSP crashed, and the LSP functionality goes away. This doesn't happen on all bazel repos -- in other codebases it works just fine. I tested using 0.1.14 and after upgrading to 0.1.21 and had the same issue on both.
How would you recommend debugging this? Do you have any pointers towards a fix? Thanks!
[2025-01-09T19:41:00Z INFO starpls::commands::server] starpls, v0.1.21
[2025-01-09T19:41:00Z DEBUG starpls::event_loop] initializing state and starting event loop
[2025-01-09T19:41:00Z DEBUG starpls::server] fetching Bazel configuration using Bazel executable at "bazel"
[2025-01-09T19:41:01Z INFO starpls::bazel] workspace root: "/Users/<my workspace path>"
[2025-01-09T19:41:01Z INFO starpls::bazel] workspace name: Some("<my workspace name>")
[2025-01-09T19:41:01Z INFO starpls::bazel] starlark-semantics: "StarlarkSemantics{}"
[2025-01-09T19:41:01Z INFO starpls::bazel] bzlmod_enabled = false
[2025-01-09T19:41:01Z DEBUG starpls::bazel] fetching builtin rules via `bazel info build-language`
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
[Error - 2:41:01 PM] Server process exited with signal SIGABRT.
[Error - 2:41:01 PM] The Bazel LSP Client server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
Ah, I've been trying to track down this bug but it doesn't occur for most of the repos I test on (e.g. it doesn't manifest for my monorepo at work, nor for the BuildBuddy monorepo or rules_rust which is a pretty sizable rules repo with a lot of Starlark code). If things seem to start up fine but only crash after a go-to definition, that usually indicates that the language server isn't correctly handling either the file that was navigated to or one of the files that it transitively loads. To that end, if you close all editors in VSCode, then open files up one by one, are you able to isolate which file might be causing the crash? If you're able to come up with a repro, I'd be happy to prioritize the fix for this since it's been bugging me as well!
Additionally, are you using any of the experimental flags, e.g. --experimental_use_code_flow_analysis or --experimental_infer_ctx_attributes?