-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 has some cache bug that causes crashes #12158
Comments
|
I'm very suspicious of our ruff/crates/ruff_cache/src/cache_key.rs Lines 350 to 355 in f9214f9
The standard library implementation we call appears to skip separators? https://doc.rust-lang.org/src/std/path.rs.html#3083-3085 Seems weird it'd treat these paths as the same when hashing though? |
I successfully reproduced the panic (thank you so so much for the easy script) and resolved it with diff --git a/crates/ruff_cache/src/cache_key.rs b/crates/ruff_cache/src/cache_key.rs
index 1208c4010..710be29c6 100644
--- a/crates/ruff_cache/src/cache_key.rs
+++ b/crates/ruff_cache/src/cache_key.rs
@@ -350,7 +350,7 @@ impl<K: CacheKey + Ord, V: CacheKey> CacheKey for BTreeMap<K, V> {
impl CacheKey for Path {
#[inline]
fn cache_key(&self, state: &mut CacheKeyHasher) {
- self.hash(&mut *state);
+ self.to_string_lossy().hash(&mut *state);
}
} |
Ah yeesh and here's a confirmation https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=467c0f7aedcfbfb484c9ca1ec65ff406 cc @BurntSushi is this.. intentional? |
Uh that's nasty, but technically the
This is fine in hash maps where the next step is to call |
Here's a directory structure that repros:
Contents don't matter.
If you run ruff twice, you'll crash with:
The text was updated successfully, but these errors were encountered: