Skip to content

Fix SharedFrame mutex panic — handle poisoned locks gracefully #15

@CREVIOS

Description

@CREVIOS

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggpuGPU rendering pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions