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

Ruff Langauge Server crash #573

Open
david-waterworth opened this issue Aug 7, 2024 · 7 comments
Open

Ruff Langauge Server crash #573

david-waterworth opened this issue Aug 7, 2024 · 7 comments
Labels
needs-mre Needs more information for reproduction server

Comments

@david-waterworth
Copy link

Sorry I cannot create code snippet for this, but I noticed these messages in my log. I think they occurred when I was dragging a vscode notebooks cell from one position to another (i.e. if I started with cells #1,#2 and #3 then I'm grabbing #2 with my mouse and moving it after #3)

I'm running ruff==0.5.6 with ruff extension version v2024.36.0 in vscode 1.92.0 on ubuntu 22.04

024-08-07 16:20:18.190 [info] panicked at crates/ruff_source_file/src/line_index.rs:176:13:
index out of bounds: the len is 1 but the index is 16

2024-08-07 16:20:18.245 [info]    0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: start_thread
             at ./nptl/pthread_create.c:442:8
  15: __GI___clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
@MichaReiser MichaReiser added bug Something isn't working server labels Aug 7, 2024
@dhruvmanila
Copy link
Member

Interesting, the reproduction steps seems similar to astral-sh/ruff#12575 but here it's a panic instead. I think it's going to be a bit difficult to reproduce this without a code snippet.

It's most likely occurring in this function (https://github.com/astral-sh/ruff/blob/1a8fd7fb91e110a1e559f7f028b710986df10666/crates/ruff_server/src/edit/range.rs#L174-L207).

@dhruvmanila
Copy link
Member

Does all the three cells contain Python code? Are there any cells that were markdown instead?

@david-waterworth
Copy link
Author

Yeah there were markdown and python cells, I think the one I was dragging was Python.

@dhruvmanila
Copy link
Member

I'm playing around with a mix of markdown / code cells and moving them around randomly but I don't see crash :(

@dhruvmanila
Copy link
Member

Huh, this did give me the following (unrelated) panic though:

2024-08-07 15:37:33.967 [info] panicked at crates/ruff_server/src/server/api/requests/format.rs:67:10:
format should only be called on text documents or notebook cells

2024-08-07 15:37:33.975 [info]    0: std::backtrace::Backtrace::force_capture
   1: ruff_server::server::Server::run
   2: std::panicking::rust_panic_with_hook
   3: <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box
   4: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::format::Format as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: ruff_server::session::Session::take_snapshot
  10: ruff_python_trivia::pragmas::is_pragma_comment
  11: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  12: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  13: std::sys::pal::unix::thread::Thread::new
  14: __pthread_joiner_wake

And, then the editor hangs at "Saving 'issue.ipynb'"

@david-waterworth
Copy link
Author

Haven't managed to repeat it today, but instead I got this (which I cannot replicate at this stage either)

2024-08-08 08:42:03.415 [info] panicked at crates/ruff_server/src/server/api/requests/hover.rs:36:10:
hover should only be called on text documents or notebook cells

2024-08-08 08:42:03.470 [info]    0: ruff_server::server::Server::run::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::option::expect_failed
   7: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::
2024-08-08 08:42:03.470 [info] BackgroundDocumentRequestHandler>::run_with_snapshot
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: std::sys_common::backtrace::__rust_begin_short_backtrace
  11: core::ops::function::FnOnce::call_once{{vtable.shim}}
  12: std::sys::pal::unix::thread::Thread::new::thread_start
  13: start_thread
             at ./nptl/pthread_create.c:442:8
  14: __GI___clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@dhruvmanila
Copy link
Member

Yeah, I got that as well which I'm tracking it in #575

@dhruvmanila dhruvmanila added needs-mre Needs more information for reproduction and removed bug Something isn't working labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-mre Needs more information for reproduction server
Projects
None yet
Development

No branches or pull requests

3 participants