Closed dxdjgl closed 4 years ago
Unhandled Exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: offset at NetMQ.Msg.Slice(Int32 offset) at NetMQ.Core.Patterns.XPub.XReadActivated(Pipe pipe) at NetMQ.Core.Patterns.XPub.XAttachPipe(Pipe pipe, Boolean icanhasall) at NetMQ.Core.Patterns.Pub.XAttachPipe(Pipe pipe, Boolean icanhasall) at NetMQ.Core.SocketBase.ProcessBind(Pipe pipe) at NetMQ.Core.ZObject.ProcessCommand(Command cmd) at NetMQ.Core.SocketBase.ProcessCommands(Int32 timeout, Boolean throttle) at NetMQ.Core.SocketBase.TrySend(Msg& msg, TimeSpan timeout, Boolean more) at NetMQ.NetMQSocket.TrySend(Msg& msg, TimeSpan timeout, Boolean more) at NetMQ.OutgoingSocketExtensions.Send(IOutgoingSocket socket, Msg& msg, Boolean more) at NetMQ.OutgoingSocketExtensions.SendFrame(IOutgoingSocket socket, Byte[] data, Int32 length, Boolean more) at NetMQ.OutgoingSocketExtensions.SendMultipartMessage(IOutgoingSocket socket, NetMQMessage message) at curveServer.Program.ServerThread(Object obj) in d:\Repo\NetMq\curveServer\Program.cs:line 44 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 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(Object obj)
By looking at the code I believe the bug was introduced with this commit, 8d1aee6 "Problem: we have compilation warnings" Previously the code would handle if the size became 0, however now the code blows up inside the splice method. As an experiment I have tried to change the code inside XPub.cs from
? m_subscriptions.Remove(sub.Slice(1), pipe)
: m_subscriptions.Add(sub.Slice(1), pipe);
to
? m_subscriptions.Remove(size == 1 ? new Span
Fix confirmed in 4.0.1.3
Environment
Expected behaviour
Actual behaviour
Publisher crashes when subscriber is connected
Steps to reproduce the behaviour
Run the code snippets in the attached file, it will crash when ever SubscribeToAnyTopic is used, and it will work when subscribing to a specific topic. NetMq.zip