SSL w/ Firefox causes a critical exception

Jun 29, 2009 at 8:22 PM

The errors below only seems to occasionally happen when using Firefox (my exact version is 3.0.11 on Windows 2003). Sadly this is the most information I can provide and has yet to happen when running the tutotial, only when using the server as a built DLL. Any thoughts as to what the issue might be? When one of the following errors happens, the entire application crashes (if it were an error handled by the server, I wouldn't mind.. but the uncaught exceptions caused by the Dispose/Finalize methods is a bit of a problem.

Thoughts?

System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>TestApp.vshost.exe</AppDomain><Exception><ExceptionType>System.ObjectDisposedException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Safe handle has been closed</Message><StackTrace>   at System.StubHelpers.StubHelpers.SafeHandleC2NHelper(Object pThis, IntPtr pCleanupWorkList)
   at System.Net.UnsafeNclNativeMethods.OSSOCK.WSAIoctl(SafeCloseSocket socketHandle, Int32 ioControlCode, Guid&amp;amp; guid, Int32 guidSize, IntPtr&amp;amp; funcPtr, Int32 funcPtrSize, Int32&amp;amp; bytesTransferred, IntPtr shouldBeNull, IntPtr shouldBeNull2)
   at System.Net.Sockets.Socket.LoadDisconnectEx()
   at System.Net.Sockets.Socket.get_DisconnectEx_Blocking()
   at System.Net.Sockets.Socket.Disconnect(Boolean reuseSocket)
   at HttpServer.ReusableSocketNetworkStream.Dispose(Boolean disposing)
   at System.Net.Sockets.NetworkStream.Finalize()</StackTrace><ExceptionString>System.ObjectDisposedException: Safe handle has been closed
   at System.StubHelpers.StubHelpers.SafeHandleC2NHelper(Object pThis, IntPtr pCleanupWorkList)
   at System.Net.UnsafeNclNativeMethods.OSSOCK.WSAIoctl(SafeCloseSocket socketHandle, Int32 ioControlCode, Guid&amp;amp; guid, Int32 guidSize, IntPtr&amp;amp; funcPtr, Int32 funcPtrSize, Int32&amp;amp; bytesTransferred, IntPtr shouldBeNull, IntPtr shouldBeNull2)
   at System.Net.Sockets.Socket.LoadDisconnectEx()
   at System.Net.Sockets.Socket.get_DisconnectEx_Blocking()
   at System.Net.Sockets.Socket.Disconnect(Boolean reuseSocket)
   at HttpServer.ReusableSocketNetworkStream.Dispose(Boolean disposing)
   at System.Net.Sockets.NetworkStream.Finalize()</ExceptionString></Exception></TraceRecord>

System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>TestApp.vshost.exe</AppDomain><Exception><ExceptionType>System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>An operation was attempted on something that is not a socket</Message><StackTrace>   at System.Net.Sockets.Socket.Disconnect(Boolean reuseSocket)
   at HttpServer.ReusableSocketNetworkStream.Dispose(Boolean disposing)
   at System.Net.Sockets.NetworkStream.Finalize()</StackTrace><ExceptionString>System.Net.Sockets.SocketException: An operation was attempted on something that is not a socket
   at System.Net.Sockets.Socket.Disconnect(Boolean reuseSocket)
   at HttpServer.ReusableSocketNetworkStream.Dispose(Boolean disposing)
   at System.Net.Sockets.NetworkStream.Finalize()</ExceptionString><NativeErrorCode>2736</NativeErrorCode></Exception></TraceRecord>
 

 

Jun 29, 2009 at 10:04 PM

My current work around is to add a try/catch block around the code within ReusableSocketNetworkStream.Dispose to handle the exception. I don't see how we can properly recover from these exceptions as the Dispose call is caleld by the Finalize call (GC) and there's no way we can recover from this error (nor do I think we need to). The Close call to allow the socket to be reused is the call that is failing, so I can only assume that socket has already been released/closed or was never open in the first place. Either way, the exception handler to prevent the server from crashing worked for me.

-Fraschetti

Developer
Aug 18, 2009 at 7:43 AM

I committed a fix for SSL + FireFox this evening (allowing SSL3 + TLS to be used instead of only TLS, which seemed to make Firefox much happier on my machine). I'm not sure if it would have any impact on this issue, but it's worth updating and testing.