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] new cache code causing panic in 0.0.273 #5228

Closed
Edward-Knight opened this issue Jun 20, 2023 · 2 comments · Fixed by #5229
Closed

[Panic] new cache code causing panic in 0.0.273 #5228

Edward-Knight opened this issue Jun 20, 2023 · 2 comments · Fixed by #5229

Comments

@Edward-Knight
Copy link

Running RUST_BACKTRACE=full ruff <file> on 0.0.273 resulted in this output:


error: `ruff` crashed. This indicates a bug in `ruff`. If you could open an issue at:

https://github.com/astral-sh/ruff/issues/new?title=%5BPanic%5D

quoting the executed command, along with the relevant file contents and `pyproject.toml` settings, we'd be very appreciative!

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', crates/ruff_cli/src/commands/run.rs:112:65
stack backtrace:
   0:        0x102bd4718 - _rust_eh_personality
   1:        0x10260fc84 - _main
   2:        0x102baf69c - _rust_eh_personality
   3:        0x102bd6108 - _rust_eh_personality
   4:        0x102bd5d48 - _rust_eh_personality
   5:        0x102bd5a8c - _rust_eh_personality
   6:        0x102a7d280 - _main
   7:        0x102bd6a30 - _rust_eh_personality
   8:        0x102bd67f0 - _rust_eh_personality
   9:        0x102bd6784 - _rust_eh_personality
  10:        0x102bd6778 - _rust_eh_personality
  11:        0x102c5093c - __rjem_je_witnesses_cleanup
  12:        0x102c509dc - __rjem_je_witnesses_cleanup
  13:        0x102a66e84 - _main
  14:        0x102a50cf0 - _main
  15:        0x102a2e424 - _main
  16:        0x102a26708 - _main
  17:        0x102591038 - __mh_execute_header
  18:        0x10258d788 - __mh_execute_header
  19:        0x102592328 - _main

My .ruff_cache looks like this:

$ tree .ruff_cache
.ruff_cache
├── CACHEDIR.TAG
└── content

2 directories, 1 file
$ cat .ruff_cache/CACHEDIR.TAG 
Signature: 8a477f597d28d172789f06886806bc55

Unfortunately I cannot provide the file that triggered this. This was run in a project without ruff configured, although it does have a pyproject.toml. This happens using the --isolated flag as well. Running on AArch64 macOS.

Here is the code snippet:

let package_root = package.unwrap_or_else(|| path.parent().unwrap_or(path));
let cache = caches
.as_ref()
.map(|caches| caches.get(&package_root).unwrap());

Last modified in 17f1ecd.

@Edward-Knight
Copy link
Author

Looks like #5225 was created while I wrote this, seems to be the same issue

@charliermarsh
Copy link
Member

Sorry, yeah, I'll cut a fix for this tonight. I'm just trying to reproduce first.

charliermarsh added a commit that referenced this issue Jun 20, 2023
## Summary

I haven't been able to determine why / when this is happening, but in
some cases, users are reporting that this `unwrap()` is causing a panic.
It's fine to just return `None` here and fallback to "No cache",
certainly better than panicking (while we figure out the edge case).

Closes #5225.

Closes #5228.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants