runtime: Exception in Socket.~Socket
From @ehtick on Monday, December 30, 2019 9:37:55 AM
Update a project from asp.net core 2.2 to 3.1. Run the project and the first page is shown. After clicking on a link and processing the controller a exception is thrown. This exeception kills the web process. Enabled symbol servers and saw that the exception landed in
“Object reference not set to an instance of an object.”
at System.Threading.Overlapped.Free(NativeOverlapped* nativeOverlappedPtr) in /_/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs:line 262
[CLSCompliant(false)]
public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr)
{
if (nativeOverlappedPtr == null)
throw new ArgumentNullException(nameof(nativeOverlappedPtr));
OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr)._overlapped._overlappedData = null;
OverlappedData.FreeNativeOverlapped(nativeOverlappedPtr);
}
First question is what if the OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr) returns null, should this not be tested??
Tried debugging it with the paralel task and threads and these show:
Tasks
Not Flagged 106 Awaiting Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelConnection.ExecuteAsync() Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelConnection.ExecuteAsync() Not Flagged 105 Awaiting Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ProcessRequestsAsync<TContext>(httpApplication) Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ProcessRequestsAsync<TContext>(httpApplication) Not Flagged 104 Awaiting Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync<TContext>(application) Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync<TContext>(application) Not Flagged 95 Awaiting Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.AcceptAsync(cancellationToken) Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.AcceptAsync(cancellationToken) Not Flagged 94 Awaiting Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.StartAsync() Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.StartAsync() Not Flagged 91 Awaiting Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive() Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive() Not Flagged 34 Awaiting Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(host, token) Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(host, token) Not Flagged 31 Awaiting Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(host, token, startupMessage) Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(host, token, startupMessage) Not Flagged 29 Awaiting Microsoft.AspNetCore.Hosting.WebHostExtensions.WaitForTokenShutdownAsync(host, token) Microsoft.AspNetCore.Hosting.WebHostExtensions.WaitForTokenShutdownAsync(host, token) Not Flagged 103 Active System.Array.Copy Async: <ProcessRequests>d__217`1 Not Flagged > 90 Active NtRemoveIoCompletion Async: <ProcessReceives>d__27 Not Flagged 96 Scheduled [Scheduled and waiting to run] Not Flagged 93 Scheduled [Scheduled and waiting to run] Async: <DoSend>d__28 Not Flagged 30 Scheduled [Scheduled and waiting to run]
Threads
Not Flagged 15252 0 Main Thread Main Thread System.Private.CoreLib.dll!System.Threading.ManualResetEventSlim.Wait Not Flagged 32600 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 18056 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 32816 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 36616 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 3980 0 Worker Thread coreclr.dll!HelperCanary::ThreadProc ntdll.dll!NtWaitForSingleObject Not Flagged 8552 0 Worker Thread .NET Finalizer System.Private.CoreLib.dll!System.Threading.Overlapped.Free Not Flagged 38544 0 Worker Thread coreclr.dll!DiagnosticsServerThread ntdll.dll!NtFsControlFile Not Flagged 22796 0 Worker Thread .NET Timer ntdll.dll!NtDelayExecution Not Flagged 21840 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion Not Flagged 37596 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion Not Flagged 30672 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 11924 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 29252 0 Worker Thread Console logger queue processing thread System.Private.CoreLib.dll!System.Threading.SemaphoreSlim.WaitUntilCountOrTimeout Not Flagged 22864 0 Worker Thread sni.dll!SNIAsyncWait sni.dll!SNIAsyncWait Not Flagged 38364 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 34868 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 28504 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 36808 0 Worker Thread ntdll.dll!TppWorkerThread ntdll.dll!NtWaitForWorkViaWorkerFactory Not Flagged 29996 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion Not Flagged 35048 0 Worker Thread .NET ThreadPool Worker Microsoft.Win32.Primitives.dll!Interop.Kernel32.GetMessage Not Flagged 38228 0 Worker Thread .NET ThreadPool Worker System.Private.CoreLib.dll!System.Array.Copy Not Flagged 27324 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion Not Flagged 24116 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion Not Flagged 22764 0 Worker Thread .NET ThreadPool Worker ntdll.dll!NtRemoveIoCompletion
Application is big and tried creating smaller sample but did not get it to work. The app created multiple async tasks to do maintainance jobs.
How to find which object is disposed and gets disposed again? or an other reason why this is happening?
Any help on finding the problem is appreciated 😃
Regards
Eddy
Copied from original issue: aspnet/AspNetCore#18063
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (14 by maintainers)
Commits related to this issue
- Allow devirtualizing into unconstructed types (#1218) Should have done this with #1131 but apparently I can't read code. — committed to MichalStrehovsky/runtime by MichalStrehovsky 3 years ago
@karelz just noticed this while trying to sort out the mess with my GitHub notifications. Will look into it.
Build the project, Run it
it will create a database (choose include sample data) (maybe this already crashes) If installation works then simply go to the home page and refresh it. In my case the second render crashes with the exception.
Shared the project which is a fork from nopcommerce. This code has been upgraded to work with aspnet core 3.1 and produces the problem.
https://github.com/BirdseyeviewNL/nopCommerce/tree/Update3.1
Hopes that this helps in finding the problem(s).