Skip to content

NetMQ Poller cleanup is not thread safe #1135

@SenseYang

Description

@SenseYang

Hi, I have observed frequent crashing of my app after adopting NetMQ especially when the Poller is being cleaned up. Error logs:

Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
2025-07-25T22:26:11.8724090Z at System.Collections.Generic.List`1.get_Item(Int32 index)
2025-07-25T22:26:11.8724230Z at NetMQ.Core.SocketBase.ProcessTerm(Int32 linger)
2025-07-25T22:26:11.8724360Z at NetMQ.Core.Own.Terminate()
2025-07-25T22:26:11.8724485Z at NetMQ.Core.SocketBase.StartReaping(Poller poller)
2025-07-25T22:26:11.8724618Z at NetMQ.Core.Reaper.ProcessReap(SocketBase socket)
2025-07-25T22:26:11.8724748Z at NetMQ.Core.ZObject.ProcessCommand(Command cmd)
2025-07-25T22:26:11.8724868Z at NetMQ.Core.Reaper.InEvent()
2025-07-25T22:26:11.8724974Z at NetMQ.Core.Utils.Poller.Loop()
2025-07-25T22:26:11.8725162Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
2025-07-25T22:26:11.8725338Z --- End of stack trace from previous location ---
2025-07-25T22:26:11.8725505Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

It seems SocketBase should at least add more thread safety checks, or handle termination exceptions better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions