-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Problem
`SharedFrame` uses `Mutex::lock().unwrap()` in multiple places. If another thread panics while holding the lock, subsequent `.unwrap()` calls will panic too, crashing the entire app.
Affected call sites:
- `begin_write()` — line ~91 in `shared_frame.rs`
- `publish()` — line ~127 in `shared_frame.rs`
- `update_full()` — line ~107 in `shared_frame.rs`
- `wait_for_frame()` — line ~167 in `shared_frame.rs`
- `dimensions()` — line ~173 in `shared_frame.rs`
Fix
Replace all `.lock().unwrap()` with `.lock().unwrap_or_else(|e| e.into_inner())`:
```rust
// Before:
let mut inner = self.inner.lock().unwrap();
// After:
let mut inner = self.inner.lock().unwrap_or_else(|e| {
log::warn!("SharedFrame mutex was poisoned, recovering");
e.into_inner()
});
```
This recovers from a poisoned mutex by extracting the data regardless. The inner operations are infallible memcpy, so the data is still valid even if the previous holder panicked.
Files to modify
- `src-tauri/src/renderer/shared_frame.rs` — all `.lock().unwrap()` calls
Priority: P1 — prevents crash in production
Reactions are currently unavailable