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

Panic when rendering Label documentation #41

Closed
hauserx opened this issue Jun 26, 2024 · 1 comment · Fixed by #44 or #45
Closed

Panic when rendering Label documentation #41

hauserx opened this issue Jun 26, 2024 · 1 comment · Fixed by #44 or #45

Comments

@hauserx
Copy link
Contributor

hauserx commented Jun 26, 2024

Getting following stack trace in bazel-lsp, after some auto-completion suggestion are being loaded. Looks like the Label symbol is global and when documentation for it is being loaded the server fails.

Not sure why it does not occur for others though, for me it happens with each usage of bazel-lsp, making it unusable.

#7  0x0000555ebb0da226 in core::option::unwrap_failed () at library/core/src/option.rs:1978
#8  0x0000555ebb68d7bc in core::option::Option<&str>::unwrap<&str> (self=...) at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/option.rs:931
#9  starlark::docs::markdown::render_function_parameters::{closure#2} (output="") at external/rules_rust~~crate~crates__starlark-0.12.0/src/docs/markdown.rs:151
#10 0x0000555ebb661dc2 in core::iter::adapters::filter_map::filter_map_fold::{closure#0}<&&starlark::docs::DocParam, (&alloc::string::String, &core::option::Option<starlark::docs::DocString>), alloc::string::String, starlark::docs::markdown::render_function_parameters::{closure_env#1}, starlark::docs::markdown::render_function_parameters::{closure_env#2}> (acc="", item=0x555ebdf10030) at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/iter/adapters/filter_map.rs:39
#11 0x0000555ebb8aa867 in core::slice::iter::{impl#181}::fold<&starlark::docs::DocParam, alloc::string::String, core::iter::adapters::filter_map::filter_map_fold::{closure_env#0}<&&starlark::docs::DocParam, (&alloc::string::String, &core::option::Option<starlark::docs::DocString>), alloc::string::String, starlark::docs::markdown::render_function_parameters::{closure_env#1}, starlark::docs::markdown::render_function_parameters::{closure_env#2}>> (self=..., init="", f=...)
    at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/slice/iter/macros.rs:232
#12 0x0000555ebb6582ec in core::iter::adapters::filter_map::{impl#2}::fold<(&alloc::string::String, &core::option::Option<starlark::docs::DocString>), core::slice::iter::Iter<&starlark::docs::DocParam>, starlark::docs::markdown::render_function_parameters::{closure_env#1}, alloc::string::String, starlark::docs::markdown::render_function_parameters::{closure_env#2}> (self=..., init=<error reading variable: Cannot access memory at address 0x0>, fold=...) at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/iter/adapters/filter_map.rs:148
#13 0x0000555ebb68d3ee in starlark::docs::markdown::render_function_parameters (params=&[starlark::docs::DocParam](size=1) = {...}) at external/rules_rust~~crate~crates__starlark-0.12.0/src/docs/markdown.rs:139
#14 0x0000555ebb68dfcc in starlark::docs::markdown::render_function (name="Label", function=0x7fff51bb61f8) at external/rules_rust~~crate~crates__starlark-0.12.0/src/docs/markdown.rs:175
#15 0x0000555ebb68f1bb in starlark::docs::markdown::render_doc_member (name="Label", item=0x7fff51bb61f8) at external/rules_rust~~crate~crates__starlark-0.12.0/src/docs/markdown.rs:265
#16 0x0000555ebb29933f in starlark_lsp::server::{impl#8}::get_global_symbol_completion_items::{closure#0}<bazel_lsp::bazel::BazelContext<bazel_lsp::client::BazelCli>> () at external/rules_rust~~crate~crates__starlark_lsp-0.12.0/src/server.rs:918

Created provisional fix:facebook/starlark-rust#121

With the fix I get following documentation, note that input parameter has no documentation:

image

bazel version: 7.1.0, --noenable_bzlmod
os: WSL2, Ubuntu 22.04
Using neovim lsp integration

@cameron-martin
Copy link
Owner

Although the problem is in starlark-rust, we can work around this by not generating empty documentation. I'll put up a fix for this.

cameron-martin added a commit that referenced this issue Jun 29, 2024
starlark-rust panics if a DocString is given that contains an empty summary. In response, we filter out empty summaries and don't generate any DocString for these.

Fixes #41
cameron-martin added a commit that referenced this issue Jun 29, 2024
starlark-rust panics if a DocString is given that contains an empty
summary. In response, we filter out empty summaries and don't generate
any DocString for these.

Fixes #41
cameron-martin added a commit that referenced this issue Jun 29, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.6.1](v0.6.0...v0.6.1)
(2024-06-29)


### Bug Fixes

* Don't give empty documentation to starlark-rust
([#44](#44))
([355ceed](355ceed)),
closes [#41](#41)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
facebook-github-bot pushed a commit to facebook/buck2 that referenced this issue Jul 1, 2024
Summary:
Fix for cameron-martin/bazel-lsp#41 - Panic when rendering Label documentation

Looks like documentation may contain no lines (in case of bazel-lsp at least), and this quick fix makes it work. Not sure whether it's the best solution, or the assumption that docs should contain non-empty text should be enforced somewhere, but it is not at this point so making it not panic seems like good solution.

X-link: facebook/starlark-rust#121

Reviewed By: perehonchuk

Differential Revision: D59208773

Pulled By: ndmitchell

fbshipit-source-id: 00708614a9e4fb53e1eaf4f41bedcae1fd4176f9
facebook-github-bot pushed a commit to facebook/starlark-rust that referenced this issue Jul 1, 2024
Summary:
Fix for cameron-martin/bazel-lsp#41 - Panic when rendering Label documentation

Looks like documentation may contain no lines (in case of bazel-lsp at least), and this quick fix makes it work. Not sure whether it's the best solution, or the assumption that docs should contain non-empty text should be enforced somewhere, but it is not at this point so making it not panic seems like good solution.

Pull Request resolved: #121

Reviewed By: perehonchuk

Differential Revision: D59208773

Pulled By: ndmitchell

fbshipit-source-id: 00708614a9e4fb53e1eaf4f41bedcae1fd4176f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants