dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.16k stars 9.92k forks source link

SslState crash #8740

Closed 30e525f9 closed 5 years ago

30e525f9 commented 5 years ago

Just one more crash while migrating net472 application to netcoreapp2.2. Application is a Windows service, uses SNI. Previous report: https://github.com/aspnet/AspNetCore/issues/8705 Minidump is sent to @GrabYourPitchforks by email

Message

Unhandled exception at 0x00007FFC99264078 (KERNELBASE.dll) in api.mql5.dmp: 0xE0434352 (parameters: 0xFFFFFFFF80131620, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FFC8BF10000).

Stack trace

KERNELBASE.dll!RaiseException()
[Managed to Native Transition]
System.Net.Security.dll!System.Net.Security.SslState.StartReadFrame(byte[] buffer, int readBytes, System.Net.AsyncProtocolRequest asyncRequest) Line 871
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(871)
System.Net.Security.dll!System.Net.Security.SslState.StartReceiveBlob(byte[] buffer, System.Net.AsyncProtocolRequest asyncRequest) Line 863
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(863)
System.Net.Security.dll!System.Net.Security.SslState.CheckCompletionBeforeNextReceive(System.Net.Security.ProtocolToken message, System.Net.AsyncProtocolRequest asyncRequest) Line 820
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(820)
System.Net.Security.dll!System.Net.Security.SslState.StartSendBlob(byte[] incoming, int count, System.Net.AsyncProtocolRequest asyncRequest) Line 791
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(791)
System.Net.Security.dll!System.Net.Security.SslState.ProcessReceivedBlob(byte[] buffer, int count, System.Net.AsyncProtocolRequest asyncRequest) Line 960
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(960)
System.Net.Security.dll!System.Net.Security.SslState.StartReadFrame(byte[] buffer, int readBytes, System.Net.AsyncProtocolRequest asyncRequest) Line 915
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(915)
System.Net.Security.dll!System.Net.Security.SslState.StartReceiveBlob(byte[] buffer, System.Net.AsyncProtocolRequest asyncRequest) Line 863
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(863)
System.Net.Security.dll!System.Net.Security.SslState.ForceAuthentication(bool receiveFirst, byte[] buffer, System.Net.AsyncProtocolRequest asyncRequest) Line 656
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(656)
System.Net.Security.dll!System.Net.Security.SslState.ProcessAuthentication(System.Net.LazyAsyncResult lazyResult = {System.Net.LazyAsyncResult}) Line 575
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslState.cs(575)
System.Net.Security.dll!System.Net.Security.SslStream.BeginAuthenticateAsServer(System.Net.Security.SslServerAuthenticationOptions sslServerAuthenticationOptions, System.Threading.CancellationToken cancellationToken, System.AsyncCallback asyncCallback, object asyncState) Line 266
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.cs(266)
System.Net.Security.dll!System.Net.Security.SslStream.AuthenticateAsServerAsync.AnonymousMethod__51_0(System.Net.Security.SslServerAuthenticationOptions arg1, System.Threading.CancellationToken arg2, System.AsyncCallback callback, object state) Line 429
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.cs(429)
System.Private.CoreLib.dll!System.Threading.Tasks.TaskFactory<System.Threading.Tasks.VoidTaskResult>.FromAsyncImpl<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken>(System.Func<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken, System.AsyncCallback, object, System.IAsyncResult> beginMethod, System.Func<System.IAsyncResult, System.Threading.Tasks.VoidTaskResult> endFunction = null, System.Action<System.IAsyncResult> endAction = {System.Action<System.IAsyncResult>}, System.Net.Security.SslServerAuthenticationOptions arg1, System.Threading.CancellationToken arg2, object state, System.Threading.Tasks.TaskCreationOptions creationOptions) Line 1058
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\Tasks\FutureFactory.cs(1058)
System.Private.CoreLib.dll!System.Threading.Tasks.TaskFactory.FromAsync<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken>(System.Func<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken, System.AsyncCallback, object, System.IAsyncResult> beginMethod, System.Action<System.IAsyncResult> endMethod, System.Net.Security.SslServerAuthenticationOptions arg1, System.Threading.CancellationToken arg2, object state, System.Threading.Tasks.TaskCreationOptions creationOptions) Line 1054
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\Tasks\TaskFactory.cs(1054)
System.Private.CoreLib.dll!System.Threading.Tasks.TaskFactory.FromAsync<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken>(System.Func<System.Net.Security.SslServerAuthenticationOptions, System.Threading.CancellationToken, System.AsyncCallback, object, System.IAsyncResult> beginMethod, System.Action<System.IAsyncResult> endMethod, System.Net.Security.SslServerAuthenticationOptions arg1, System.Threading.CancellationToken arg2, object state) Line 1015
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\Tasks\TaskFactory.cs(1015)
[Native to Managed Transition]
[Managed to Native Transition]
System.Net.Security.dll!System.Net.Security.SslStream.AuthenticateAsServerAsync(System.Net.Security.SslServerAuthenticationOptions sslServerAuthenticationOptions, System.Threading.CancellationToken cancellationToken) Line 428
    at E:\A\_work\20\s\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.cs(428)
Microsoft.AspNetCore.Server.Kestrel.Core.dll!Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.ConnectionAdapterContext context = {Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.ConnectionAdapterContext}) Line 174
    at /_/src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs(174)
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.Task<Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.IAdaptedConnection>>.InnerInvoke() Line 610
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\Tasks\future.cs(610)
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 167
    at E:\A\_work\287\s\src\mscorlib\shared\System\Threading\ExecutionContext.cs(167)
System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot = Id = 1, Status = Running, Method = Inspecting the state of an object in the debuggee of type System.Delegate is not supported while minidump debugging., Result = "{Not yet computed}") Line 2440
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\Tasks\Task.cs(2440)
System.Private.CoreLib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Line 588
    at E:\A\_work\287\s\src\mscorlib\src\System\Threading\ThreadPool.cs(588)
[Native to Managed Transition]
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

Screenshots

image

Additional context

dotnet --info:

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  No SDKs were found.

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Packages used:

<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.2.2" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="2.0.1" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
GrabYourPitchforks commented 5 years ago

I got your email and will take a look with the team. Thanks!

30e525f9 commented 5 years ago

App keeps crashing. EventLog points to Access Violation error (code c0000005):

Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFCA14FD149 (00007FFCA1340000) with exit code c0000005.

While the dump created by DebugDiag tool pointing to same EOF handling code as above:

        private void StartReadFrame(byte[] buffer, int readBytes, AsyncProtocolRequest asyncRequest)
        {
            if (readBytes == 0)
            {
                // EOF received
                throw new IOException(SR.net_auth_eof); // Unhandled exception at 0x00007FFCAA7A8E6C (KERNELBASE.dll) in api.mql5.dmp: 0xE0434352 (parameters: 0xFFFFFFFF80131620, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FFCA1340000).
            }
30e525f9 commented 5 years ago

OK. I found a bug in my own code by creating an Access Violation-specific rule in DebugDiag. Otherwise it catches random exceptions massively generated within Kestrel.