Skip to content

Infinite loop in RequestSocket SendMultipartMessage #1139

@rickshaw5724

Description

@rickshaw5724

I have a field installation where I have a request socket sending a message to another process with a RouterSocket. I noticed the process with the request socket was using a lot of CPU. I created a full dump of the process, waited 5 minutes, and created a second dump. The thread that has been using CPU over the last 24 hours has used 18 hours worth of CPU, so it is run-bound.

What I believe happened: I believe my client instance was disposed while a request was in process. Clearly, I should be able to address that through thread synchronization, but it made me think perhaps I should raise this issue to get the thoughts of others.

Here is the callstack of the long running thread:

 	System.Private.CoreLib.dll!System.ThrowHelper.ThrowObjectDisposedException(object instance)	Unknown
 	System.Net.Sockets.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode)	Unknown
 	NetMQ.dll!NetMQ.Core.Utils.Signaler.Recv() Line 81	C#
 	NetMQ.dll!NetMQ.Core.Mailbox.TryRecv(int timeout, out NetMQ.Core.Command command) Line 49	C#
 	NetMQ.dll!NetMQ.Core.SocketBase.ProcessCommands(int timeout, bool throttle, System.Threading.CancellationToken cancellationToken) Line 781	C#
>	NetMQ.dll!NetMQ.Core.SocketBase.TrySend(ref NetMQ.Msg msg, System.TimeSpan timeout, bool more) Line 627	C#
 	NetMQ.dll!NetMQ.OutgoingSocketExtensions.Send(NetMQ.IOutgoingSocket socket, ref NetMQ.Msg msg, bool more) Line 12	C#
 	NetMQ.dll!NetMQ.OutgoingSocketExtensions.SendMultipartMessage(NetMQ.IOutgoingSocket socket, NetMQ.NetMQMessage message) Line 190	C#

OutgoingSocketExtensions.Send calls socket.TrySend with a SendRecieveConstants.InfiniteTimeout. Mailbox.TryRecv will catch all exceptions, so the ObjectDisposedException on the top of the stack will be caught here and false will be returned to ProcessCommands. That returns to ProcessCommands which then returns to SocketBase.TrySend which is in a while(true) loop that will remain there because the timeout is -1 and XSend never returns true.

It seems like we should somehow break out of that loop.

Metadata

Metadata

Assignees

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