Skip to content

Fix deadlock on Ctrl+C in server mode#1649

Merged
st0012 merged 1 commit intomasterfrom
fix-server-ctrl-c
Mar 16, 2026
Merged

Fix deadlock on Ctrl+C in server mode#1649
st0012 merged 1 commit intomasterfrom
fix-server-ctrl-c

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 16, 2026

Summary

  • Pressing Ctrl+C in rdoc --server raised ThreadError: deadlock; recursive locking because the INT trap called shutdown, which closed the TCP server socket from the same thread blocked on accept
  • Replace trap-based shutdown with rescue Interrupt around the accept loop, and move cleanup into an ensure block

@st0012 st0012 added the bug label Mar 16, 2026
@matzbot
Copy link
Collaborator

matzbot commented Mar 16, 2026

🚀 Preview deployment available at: https://55e27193.rdoc-6cd.pages.dev (commit: b3cf697)

@st0012 st0012 marked this pull request as ready for review March 16, 2026 00:09
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@st0012 st0012 force-pushed the fix-server-ctrl-c branch from aba78d5 to 7286f8e Compare March 16, 2026 11:07
The INT/TERM trap handler called shutdown, which closed the TCP server
socket from the same thread blocked on accept, causing a
ThreadError (deadlock; recursive locking).

Replace the trap-based shutdown with rescue Interrupt around the
accept loop.  Move cleanup into an ensure block so it runs on any
exit path.
@st0012 st0012 force-pushed the fix-server-ctrl-c branch from 7286f8e to b3cf697 Compare March 16, 2026 11:08
@st0012 st0012 merged commit 237f113 into master Mar 16, 2026
77 checks passed
@st0012 st0012 deleted the fix-server-ctrl-c branch March 16, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants