Skip to content

fix(locks): degrade instead of crashing on a poisoned grid lock#51

Open
roramirez wants to merge 1 commit into
mainfrom
hardening/03-poison-locks
Open

fix(locks): degrade instead of crashing on a poisoned grid lock#51
roramirez wants to merge 1 commit into
mainfrom
hardening/03-poison-locks

Conversation

@roramirez

@roramirez roramirez commented Jun 30, 2026

Copy link
Copy Markdown
Owner

What

A panic in a parser thread while it holds a pane's grid write lock poisons that RwLock; every main-thread .read()/.write().unwrap() then panicked in cascade, taking down the whole app.

Changes

  • Poison-tolerant Pane::grid_read / Pane::grid_write helpers that log a warning and return None.
  • Migrate the ~30 main-thread acquisitions (render, input, search, scroll, resize, restore, paste, toggle-log) to skip the frame/action on poison instead of panicking.
  • The parser thread's own writes are left as-is: a thread cannot observe poison it caused itself.

Tests

  • Regression test that poisons the active pane's grid and confirms update_search_matches / active_grid_rows / scroll_up / scroll_top degrade without panicking.

Card

plan-todo/03-hardening-unwrap-locks.md

A panic in a parser thread while it holds a pane's grid write lock poisons
that RwLock; every main-thread `.read()/.write().unwrap()` then panicked in
cascade, taking down the whole app. Add poison-tolerant `Pane::grid_read`
and `Pane::grid_write` helpers that log a warning and return `None`, and
migrate the ~30 main-thread grid/log_file/pending_resize acquisitions
(render, input, search, scroll, resize, restore, paste, toggle-log) to skip
the frame/action on poison rather than panic. The parser thread's own
writes are left as-is — a thread cannot observe poison it caused itself.

Add a regression test that poisons the active pane's grid and confirms
update_search_matches / active_grid_rows / scroll_up / scroll_top return
degraded values without panicking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant