I'm running a server app under mono on debian 9. Around 1000-2000 clients are connected and quite often the application freezes with 100% cpu usage. I do "kill -QUIT pid" to get thread stack dump and it's always stuck at this:
"<unnamed thread>" at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Net.Sockets.Socket.Send_internal (intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool) [0x00000] in <2b0d86369d72459baed0cee98a8e578a>:0
at System.Net.Sockets.Socket.Send_internal (System.Net.Sockets.SafeSocketHandle,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool) [0x0000c] in <2b0d86369d72459baed0cee98a8e578a>:0
at System.Net.Sockets.Socket.Send (byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.Sockets.SocketError&) [0x00021] in <2b0d86369d72459baed0cee98a8e578a>:0
After about 10-20 minutes the freeze ends and application resumes. Any ideas why this could be happening and what I could do?
This is a non-blocking socket and isn't a regular blocking call as the CPU usage is always 100% during this.
Edit: solved it. There's a infinite loop in mono implementation of Socket.Send, removing it fixed the issue completely.