Skip to content

Mailbox.TryRead still throwing in debug mode #1092

Closed
@tmatthey

Description

@tmatthey

Environment

NetMQ Version:    4.0.1.13 with [PR 1087](https://github.com/zeromq/netmq/pull/1087) debug mode
Operating System:  Alpine Linux
.NET Version:   standard 2.0  

Expected behaviour

Mailbox.TryRead should not throw when returning a command for debug mode.

Actual behaviour

When run in debug mode Debug.Assert(ok); may throw since m_commandPipe.TryRead may return false:

Process terminated. Assertion failed.
   at NetMQ.Core.Mailbox.TryRecv(Int32 timeout, Command& command)
   at NetMQ.Core.SocketBase.ProcessCommands(Int32 timeout, Boolean throttle, CancellationToken cancellationToken)
   at NetMQ.Core.SocketBase.GetSocketOptionX(ZmqSocketOption option)
   at NetMQ.NetMQSocket.GetSocketOptionX[T](ZmqSocketOption option)
   at NetMQ.NetMQSocket.get_HasIn()

Steps to reproduce the behaviour

A one-off on Alpine Linux, most probably when DNS disappears.

How to potentially fix

Remove Debug.Assert(ok);, just return value of m_commandPipe.TryRead. I'm not certain if caller of Mailbox.TryRead may check if command.Destination to be not zero when processing the command, i.e., reading a command with CommandType.Done sent by ZObject.SendDone(), which has no destination.

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