Commit 4cd0893
fix: ensure canonicalized paths remain accessible via strong references (#733)
## Summary
- Fixes #732 - "Canonicalized path was dropped" error that could occur
in CI environments
- Ensures canonicalized paths have at least one strong reference in the
cache to prevent premature dropping
- Adds comprehensive tests to prevent regression
## Problem
The resolver was experiencing "Canonicalized path was dropped" errors
due to weak references being used without ensuring a strong reference
existed. When `canonicalize_impl` stored only weak references to
canonicalized paths, if those paths weren't already in the cache, the
Arc would be immediately dropped, causing the weak reference to fail on
upgrade.
## Solution
Modified `canonicalize_impl` in `src/cache/cache_impl.rs` to ensure
canonicalized paths are added to the cache (if not already present)
before downgrading to weak references. This maintains at least one
strong reference while preserving the weak reference pattern needed to
avoid memory leaks from circular references.
## Test Plan
- [x] Added `test_canonicalized_path_not_dropped` to verify
canonicalization works correctly
- [x] Added `test_canonicalized_path_weak_reference` to ensure the error
doesn't occur
- [x] All existing tests pass, including the memory leak test
- [x] `cargo test` passes
- [x] `cargo clippy` passes
- [x] `cargo check` passes
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <[email protected]>1 parent 7c29092 commit 4cd0893
2 files changed
+69
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
274 | 283 | | |
275 | 284 | | |
276 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
0 commit comments