2

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.

Duckbat
  • 21
  • 2
  • hard to tell because the actual implementation of Send_internal is in an external (OS specific) library and not part of the mono source code. But [this suggests](https://github.com/mono/mono/blob/1063240b8656d5403f807cc52efa4edf1f8a1818/mcs/class/System/System.Net.Sockets/Socket.cs#L2017) that it is a blocking system call. – Cee McSharpface Nov 24 '17 at 16:42
  • Wouldn't a blocking system call use 0% cpu though? And I do this to every socket just after it has been accepted:Socket.Blocking = false; – Duckbat Nov 24 '17 at 17:18

0 Answers0