Skip to content

Cannot close an uninitialised Msg. #1054

Open
@LarsHesselberg

Description

@LarsHesselberg

Environment

NetMQ Version:  4.0.1.6+e86706ffb913825b3bc0e1048...  
Operating System: Win10
.NET Version:     4.7

Expected behaviour

No exception

Actual behaviour


Exception Message: Cannot close an uninitialised Msg.
Exception Stack Trace: 
   at NetMQ.Msg.Close()
   at NetMQ.Core.Transports.EncoderBase.Encode(ByteArraySegment& data, Int32 size)
   at NetMQ.Core.Transports.StreamEngine.BeginSending()
   at NetMQ.Core.Transports.StreamEngine.Handle(Action action, SocketError socketError, Int32 bytesTransferred)
   at NetMQ.Core.Transports.StreamEngine.FeedAction(Action action, SocketError socketError, Int32 bytesTransferred)
   at NetMQ.Core.ZObject.ProcessCommand(Command cmd)
   at NetMQ.Core.IOThread.Ready()
   at NetMQ.Core.Utils.Proactor.Loop()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Steps to reproduce the behaviour

Appears randomly - mostly under heavy load.

Examining the NetMQ code it looks like the issue occurs in EncoderBase.cs Encode function here:

                // If there are no more data to return, run the state machine.
                // If there are still no data, return what we already have
                // in the buffer.
                if (m_toWrite == 0)
                {
                    if (m_newMsgFlag) {
                        m_inProgress.Close();  ** <-- Here: m_inProgress.MsgType maybe  MsgType.Uninitialised. Put in if (m_inProgress.IsInitialised) **
                        m_inProgress.InitEmpty();
                        m_hasMessage = false;
                        break;
                    }

                    Next();
                }

I point at this place because following the call-tree it is the only place I can find where Msg could be Uninitialised.

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