Fix unhandled SocketException on Proactor/Poller I/O threads crashing the process#1155
Draft
Copilot wants to merge 3 commits into
Draft
Fix unhandled SocketException on Proactor/Poller I/O threads crashing the process#1155Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/zeromq/netmq/sessions/6e0add68-02af-40f0-98b0-628109059d26 Co-authored-by: drewnoakes <350947+drewnoakes@users.noreply.github.com>
Agent-Logs-Url: https://github.com/zeromq/netmq/sessions/6e0add68-02af-40f0-98b0-628109059d26 Co-authored-by: drewnoakes <350947+drewnoakes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix unhandled SocketException on Proactor I/O thread
Fix unhandled SocketException on Proactor/Poller I/O threads crashing the process
May 1, 2026
There was a problem hiding this comment.
Pull request overview
This PR aims to stop NetMQ background threads from terminating the process when the loopback signaling socket used for inter-thread notifications throws a SocketException. It changes the low-level event loops that power I/O threads (Proactor) and the reaper thread (Poller).
Changes:
- Add a
catch (SocketException)toProactor.Loop()so unhandled socket exceptions do not escape the I/O thread. - Add the same
catch (SocketException)toPoller.Loop()for the reaper/poller thread. - Add
using System.Net.Sockets;toProactor.csto support the new catch block.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/NetMQ/Core/Utils/Proactor.cs |
Adds loop-level SocketException handling around per-completion processing in the proactor-based I/O thread. |
src/NetMQ/Core/Utils/Poller.cs |
Adds loop-level SocketException handling around InEvent() dispatch in the select-based poller used by the reaper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+317
to
+324
| catch (SocketException) | ||
| { | ||
| // A SocketException can be thrown by Signaler.Send() when the loopback | ||
| // TCP socket pair used for inter-thread signaling fails (e.g. when all | ||
| // network traffic is blocked by a firewall or network simulation tool). | ||
| // Swallow the exception so the Poller loop continues rather than | ||
| // crashing the thread. | ||
| } |
Comment on lines
+143
to
+149
| catch (SocketException) | ||
| { | ||
| // A SocketException can be thrown by Signaler.Send() when the loopback | ||
| // TCP socket pair used for inter-thread signaling fails (e.g. when all | ||
| // network traffic is blocked by a firewall or network simulation tool). | ||
| // Swallow the exception so the Proactor loop continues processing other | ||
| // completions rather than crashing the process. |
Comment on lines
+143
to
+149
| catch (SocketException) | ||
| { | ||
| // A SocketException can be thrown by Signaler.Send() when the loopback | ||
| // TCP socket pair used for inter-thread signaling fails (e.g. when all | ||
| // network traffic is blocked by a firewall or network simulation tool). | ||
| // Swallow the exception so the Proactor loop continues processing other | ||
| // completions rather than crashing the process. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When all network traffic is blocked (e.g., via Clumsy), the loopback TCP socket pair used by
Signalerfor inter-thread notification can also fail. This throws aSocketExceptioninsideProactor.Loop()that propagates unhandled, terminating the process — because rawThreadexceptions are non-recoverable in .NET Core.Call chain:
Proactor.Loop()→StreamEngine.Error()→SocketBase.EventDisconnected()→MonitorEvent.Write()→Mailbox.Send()→Signaler.Send()→SocketException💥Changes
Proactor.cs— Addcatch (SocketException)alongside the existingcatch (TerminatingException)inLoop(). Also adds the missingusing System.Net.Sockets;import.Poller.cs— Same fix forPoller.Loop()(used by theReaper), for defense in depth.The
SocketExceptionhere is always a secondary failure — the primary I/O error has already been handled by the completion event. Swallowing it is safe and consistent with howTerminatingExceptionis already treated.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
10.1.15.255REDACTED, pid is -1(packet block)If you need me to access, download, or install something from one of these locations, you can either: