Skip to content

Prevent native event pipe writes from deadlocking Emacs - #764

Merged
emil-e merged 2 commits into
dakra:mainfrom
emil-e:fix/native-event-pipe-deadlock
Oct 29, 2026
Merged

emil-e merged 2 commits into
dakra:mainfrom
emil-e:fix/native-event-pipe-deadlock

Conversation

@emil-e

@emil-e emil-e commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Release the terminal lock around event-buffer overflow writes, then reacquire it even if the write fails.
  • Snapshot terminal titles before event delivery, and assert unlock ownership in the recursive mutex.
  • Retain the fixed 16 KiB buffer and existing redraw batching; add a bounded deadlock regression and a synchronous title-lifetime test.

Fixes #758.

Verification

  • macOS debug build and 39 Zig tests passed.
  • Native-process ERT: 15 passed, one Windows-only test skipped.
  • Windows x86_64 debug cross-build passed; Windows runtime testing remains outstanding.
  • Reproduced the original deadlock and title corruption without the snapshot during investigation.

Keep terminal and native process state alive with reader references so buffer teardown can request stop without joining a blocked event writer. Let the detached reader finish event delivery and reap the child itself.

Extend the event-pipe backpressure regression through the real buffer-kill hook, and wait for reader allocations before Debug leak checks.
@emil-e
emil-e merged commit 43c58bc into dakra:main Oct 29, 2026
30 checks passed
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.

Native PTY: event pipe write with the terminal lock held freezes Emacs

1 participant