最近在做mono 3.10针对socket性能方面的测试,在想对压力比较高的情况下发现了mono的一个bug会导致程序引发未知异常从而导致程序结束的严重问题.
错误信息
Unhandled Exception: System.InvalidOperationException: EndSend can only be called once per asynchronous operation at System.Net.Sockets.Socket.EndSend (IAsyncResult asyncResult, System.Net.Sockets.SocketError& errorCode) [0x00000] in <filename unknown>:0 at System.Net.Sockets.Socket.EndSend (IAsyncResult result) [0x00000] in <filename unknown>:0 at System.Net.Sockets.SocketAsyncEventArgs.SendCallback (IAsyncResult ares) [0x00000] in <filename unknown>:0 at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) [0x00000] in <filename unknown>:0 epoll(ADD): 9 Bad file descriptor
从代码上来看是由Socket.EndSend引发的异常没有被处理,看样子是由epoll导面抛出的.SocketAsyncEventArgs.SendCallback的处理代码如下:
internal void SendCallback (IAsyncResult ares) { try { BytesTransferred = curSocket.EndSend (ares); } catch (SocketException se){ SocketError = se.SocketErrorCode; } catch (ObjectDisposedException) { SocketError = SocketError.OperationAborted; } finally { OnCompleted (this); } }
从代码上看来应该是有些异常没有处理,显然epool(add):9 Bad file descriptor应该是一个file io异常,由于以上代码没有catch....结果悲剧的事情发生了.(问题已经提交到mono团队,希望他们能处理一下这个问题)
时间: 2024-09-29 02:06:50