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

Frequent server panic exits – «Ruff language server exited with a panic» #607

Open
rnckp opened this issue Sep 8, 2024 · 25 comments
Open
Labels
needs-mre Needs more information for reproduction server

Comments

@rnckp
Copy link

rnckp commented Sep 8, 2024

I observe frequent server panic exits with no appearant reason. What can I do to fix this?

Note: I do not drag any cells. So this does not seem related to #575

Minimal code snippet
I do not invoke specific commands or cells. I observe the crashes throughout various of my projects in VS Code.

Settings
settings.zip

Versions
VS Code 1.93.0
Ruff extension v2024.44.0 (Auto Update active)

Environment
MacBook Pro 16'' 2023, Apple M2 Max, 64GB
MacOS Sonoma 14.6.1

Panic logs

2024-09-08 09:53:38.747 [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-09-08 09:53:38.747 [info]    0: std::backtrace::Backtrace::create
   1
2024-09-08 09:53:38.747 [info] : ruff_server::server::Server::run::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api
2024-09-08 09:53:38.748 [info] ::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: std::sys_common::backtrace::__rust_begin_short_backtrace
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: __pthread_joiner_wake


2024-09-08 10:00:51.113 [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-09-08 10:00:51.113 [info]    0: std::backtrace::
2024-09-08 10:00:51.114 [info] Backtrace::create
   1: ruff_server::server::Server::run::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: std::sys_common::backtrace::__rust_begin_short_backtrace
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: __pthread_joiner_wake
@MichaReiser
Copy link
Member

MichaReiser commented Sep 8, 2024

Hi @rnckp. I'm sorry you're running into this.

Could you tell me a bit more about your workflow so that I can reproduce this issue?

  • what kind of files you're working on
  • what operations do you perform?
  • Are you working on notebooks or "regular" Python files?
  • What other extensions have you installed?

@rnckp
Copy link
Author

rnckp commented Sep 8, 2024

@MichaReiser Thanks for your fast response!

  • I mainly work in Jupyter notebooks. This is where I observe the server crashes. I rarely have opened some .py files in parallel.
  • I observe the crashes without invoking any ruff commands. I mainly use the «Format Notebook» command within a notebook. However, the crashes occur not while invoking this command.
  • Other extensions that I have installed and are active: Jupyter, Jupyter Cell Tags, Jupyter Keymap, Jupyter Notebook Renderers, Jupyter Slide Show, MS Python, MS Python Debugger, MS Pylance, GitHub Copilot and Copilot Chat.

@MichaReiser
Copy link
Member

Hmm interesting. I played around with a notebook, even with mixed languages but haven't been able to trigger the same panic.

Would you mind restarting VS code, open a notebook, and then open Output - Ruff. You should then see something similar to

2024-09-08 12:08:03.411 [info] Server: Stop requested
2024-09-08 12:08:04.375 [info] Name: Ruff
2024-09-08 12:08:04.375 [info] Module: ruff
2024-09-08 12:08:04.375 [info] Python extension loading
2024-09-08 12:08:04.375 [info] Waiting for interpreter from python extension.
2024-09-08 12:08:04.375 [info] Python extension loaded
2024-09-08 12:08:04.375 [info] Using interpreter: /Users/micha/astral/test/.venv/bin/python
2024-09-08 12:08:04.375 [info] Using 'path' setting: /Users/micha/astral/ruff/target/debug/ruff
2024-09-08 12:08:04.386 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2024-09-08 12:08:04.387 [info] Found Ruff 0.6.4 at /Users/micha/astral/ruff/target/debug/ruff
2024-09-08 12:08:04.387 [info] Server run command: /Users/micha/astral/ruff/target/debug/ruff server

Could you share the log with me? I'm specifically interested in the ruff version.

@rnckp
Copy link
Author

rnckp commented Sep 8, 2024

Sure!

What I notice is that the used interpreter is the homebrew one. However, I use miniconda environments for all my projects. These are also the kernels that I always select when I start working in the notebooks.

2024-09-08 12:18:40.977 [info] Name: Ruff
2024-09-08 12:18:40.977 [info] Module: ruff
2024-09-08 12:18:40.977 [info] Python extension loading
2024-09-08 12:18:40.977 [info] Waiting for interpreter from python extension.
2024-09-08 12:18:40.977 [info] Python extension loaded
2024-09-08 12:18:40.977 [info] Using interpreter: /opt/homebrew/bin/python3
2024-09-08 12:18:40.977 [info] Falling back to bundled executable: /Users/teamdata/.vscode/extensions/charliermarsh.ruff-2024.44.0-darwin-arm64/bundled/libs/bin/ruff
2024-09-08 12:18:40.977 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2024-09-08 12:18:40.977 [info] Found Ruff 0.6.4 at /Users/teamdata/.vscode/extensions/charliermarsh.ruff-2024.44.0-darwin-arm64/bundled/libs/bin/ruff
2024-09-08 12:18:40.977 [info] Server run command: /Users/teamdata/.vscode/extensions/charliermarsh.ruff-2024.44.0-darwin-arm64/bundled/libs/bin/ruff server
2024-09-08 12:18:40.977 [info] Server: Start requested.

@MichaReiser
Copy link
Member

MichaReiser commented Sep 8, 2024

Thanks. Hmm. this looks all good... Maybe @dhruvmanila has an idea? It might take him a few days to reply because he's currently traveling.

@dhruvmanila
Copy link
Member

What I notice is that the used interpreter is the homebrew one. However, I use miniconda environments for all my projects. These are also the kernels that I always select when I start working in the notebooks.

Is the environment activated when you start VS Code? Regardless, the panic that you're facing doesn't seem to be related to the selected interpreter. Are you able to share the notebook where you're facing this panic? I can play around with that and try to reproduce it myself.

@rnckp
Copy link
Author

rnckp commented Sep 9, 2024

Thanks @dhruvmanila

I do activate the environment when I start working in the notebook. When I execute the first cell, VS Code let me select the environment and I choose from my miniconda environments.

I will have a look at the notebook tonight and see if I can share it.

@dhruvmanila
Copy link
Member

I do activate the environment when I start working in the notebook. When I execute the first cell, VS Code let me select the environment and I choose from my miniconda environments.

The extension should probably restart if a user changes the interpreter which should result in Ruff selecting the correct interpreter.

I will have a look at the notebook tonight and see if I can share it.

Thanks, that should be helpful.

@rnckp
Copy link
Author

rnckp commented Sep 10, 2024

Is there a way I could share the notebook directly with you, e.g. email?

@rnckp
Copy link
Author

rnckp commented Sep 10, 2024

New logs from a different notebook where I observe the server panics.

2024-09-10 12:24:26.515 [info]    1: ruff_server::server::Server::run::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: std::sys_common::backtrace::__rust_begin_short_backtrace
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: __pthread_joiner_wake


2024-09-10 12:25:07.783 [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 6

2024-09-10 12:25:07.783 [info]    0: std::backtrace::Backtrace::create
   1: ruff_server::server::Server::run::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic_bounds_check
   8: ruff_source_file::line_index::LineIndex::line_range
   9: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: core::ops::function::FnOnce::call_once{{vtable.shim}}
  12: std::sys_common::backtrace::__rust_begin_short_backtrace
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}

2024-09-10 12:25:07.783 [info]   14: std::sys::pal::unix::thread::Thread::new::thread_start
  15: __pthread_joiner_wake

@dhruvmanila
Copy link
Member

Is there a way I could share the notebook directly with you, e.g. email?

Are you on discord? I'm 'dhruvmanila' or you can email me at "[GitHub username] at gmail".

@rnckp
Copy link
Author

rnckp commented Sep 10, 2024

I have sent two sample notebooks via email.

I also noticed that the crashes occur on a different computer too (Mac mini M1 2020, Sonoma 14.6.1). VS Code is 1.93.0, Ruff v2024.46.0.

@dhruvmanila
Copy link
Member

Thanks, I tested it against the provided notebooks and I can't seem to reproduce the panic :(

Are you able to reproduce it consistently? Can you provide the steps you took which leads to the panic? Or, record a video that reproduces it? Whatever is easier for you.

@rnckp
Copy link
Author

rnckp commented Sep 11, 2024

Thanks for testing and looking into this issue!

Unfortunately I am not able to reproduce it consistently. However, when it appears, than the server usually crashes again and again. I will try to record a video and send this to you. This might take until Friday or the weekend.

@dhruvmanila
Copy link
Member

Yeah, no worries.

@MichaReiser MichaReiser added the needs-mre Needs more information for reproduction label Sep 20, 2024
@future
Copy link

future commented Sep 27, 2024

Hi,
When I used the miniconda environment on Pi5 and used vscode remote programming, similar problems also occurred... The log is as follows

2024-09-27 13:11:24.465 [info] Name: Ruff
2024-09-27 13:11:24.465 [info] Module: ruff
2024-09-27 13:11:24.465 [info] Python extension loading
2024-09-27 13:11:24.465 [info] Waiting for interpreter from python extension.
2024-09-27 13:11:24.465 [info] Python extension loaded
2024-09-27 13:11:24.465 [info] Using interpreter: /bin/python3
2024-09-27 13:11:24.506 [info] Falling back to bundled executable: /home/spark/.vscode-server/extensions/charliermarsh.ruff-2024.50.0-linux-arm64/bundled/libs/bin/ruff
2024-09-27 13:11:24.527 [info] Found Ruff 0.6.6 at /home/spark/.vscode-server/extensions/charliermarsh.ruff-2024.50.0-linux-arm64/bundled/libs/bin/ruff
2024-09-27 13:11:24.527 [info] Server run command: /home/spark/.vscode-server/extensions/charliermarsh.ruff-2024.50.0-linux-arm64/bundled/libs/bin/ruff server
2024-09-27 13:11:24.529 [info] Server: Start requested.
2024-09-27 13:13:14.564 [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-09-27 13:13:14.658 [info]    0: std::backtrace::Backtrace::create
   1: ruff_server::server::Server::run::{{closure}}
   2
2024-09-27 13:13:14.658 [info] : std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys::backtrace::__rust_end_short_backtrace
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: std::sys::backtrace::__rust_begin_short_backtrace
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: start_thread
             at ./nptl/pthread_create.c:447:8
  15: thread_start
             at ./misc/../sysdeps/unix/sysv/linux/aarch64/clone3.S:76


2024-09-27 13:13:15.212 [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-09-27 13:13:15.212 [info]    0: std::backtrace::Backtrace::create
   1: ruff_server::server::Server::run::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys::backtrace::__rust_end_short_backtrace
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}

2024-09-27 13:13:15.213 [info]   10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: std::sys::backtrace::__rust_begin_short_backtrace
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: start_thread
             at ./nptl/pthread_create.c:447:8
  15: thread_start
             at ./misc/../sysdeps/unix/sysv/linux/aarch64/clone3.S:76


@rnckp
Copy link
Author

rnckp commented Sep 30, 2024

@dhruvmanila I could record some server panics. I have sent this to you by mail.

PS: I have the feeling that the server crashes are more probable if I have more and longer text print outs in a notebook or more larger text or markdown documents in my VS Code workspace. Just a hunch. I cannot reliably confirm this.

@dhruvmanila
Copy link
Member

@rnckp Thanks! I'll look into it this week

@rnckp
Copy link
Author

rnckp commented Oct 4, 2024

@dhruvmanila I have added two more screen recordings to the Google Drive folder with the respective notebook where the crashes occur.

@dhruvmanila
Copy link
Member

@rnckp The text_simplification.ipynb file is empty in the folder.

@rnckp
Copy link
Author

rnckp commented Oct 8, 2024

@dhruvmanila Sorry about that. I just fixed it and uploaded the proper file.

@dhruvmanila
Copy link
Member

Can you provide the Ruff config that you're using? I see that in the video some of the cells are giving diagnostics but it's not doing the same for me. Also, the Ruff version and extension version that is being used.

@dhruvmanila
Copy link
Member

Nevermind, you've provided it in the issue description.

@dhruvmanila
Copy link
Member

I'm a bit confused, the pyproject.toml that you've provided is same as the one in ruff-vscode repository at https://github.com/astral-sh/ruff-vscode/blob/main/pyproject.toml, is that expected?

@rnckp
Copy link
Author

rnckp commented Oct 8, 2024

@dhruvmanila I use this pyproject.toml to include jupyter notebooks in the Ruff formatting by default per my settings. I placed it at the top level of all my git repos that I generally open in VS Code.

However, for the last tests that I did where I recorded the videos I only had opened one single repo in VS Code (not the entirety of all repos/projects). Therefore I think the .toml didn't have any effect.

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

5 participants