Project
vgrep
Description
Multiple calls to .lock().unwrap() on mutex can panic if the mutex is poisoned (another thread panicked while holding the lock), crashing the entire file watcher process.
Error Observation
If any thread panics while holding the mutex, subsequent lock attempts will panic, causing a cascading failure.
Error Message
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }'
Debug Logs
System Information
Version: 0.1.0
## Operating System
OS: Ubuntu 24.04.3 LTS
Kernel: 6.8.0-79-generic
Arch: x86_64
## Hardware
CPU: AMD Ryzen 9 5950X 16-Core Processor (4 cores)
RAM: 11 GB
## Build Environment
Rust: rustc 1.92.0 (ded5c06cf 2025-12-08)
Target: x86_64
Screenshots
No response
Steps to Reproduce
- Open
src/watcher.rs
- Examine lines 104-105, 111, 118, 142:
let should_process = {
let last = last_process.lock().unwrap(); // Can panic!
let pending = pending_files.lock().unwrap(); // Can panic!
!pending.is_empty() && last.elapsed() >= debounce_duration
};
### Expected Behavior
Should use `.unwrap_or_else(|e| e.into_inner())` to recover from poisoned mutexes.
### Actual Behavior
A panic in any thread holding these mutexes will crash the file watcher, requiring manual restart.
### Additional Context
This is a known Rust anti-pattern for production code. 5 instances at lines 104, 105, 111, 118, 142.
Project
vgrep
Description
Multiple calls to
.lock().unwrap()on mutex can panic if the mutex is poisoned (another thread panicked while holding the lock), crashing the entire file watcher process.Error Observation
If any thread panics while holding the mutex, subsequent lock attempts will panic, causing a cascading failure.
Error Message
Debug Logs
System Information
Screenshots
No response
Steps to Reproduce
src/watcher.rs