-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Net.Httpbugtenet-reliabilityReliability/stability related issue (stress, load problems, etc.)Reliability/stability related issue (stress, load problems, etc.)
Milestone
Description
We are reporting daily crashes after moving our application from .Net 4.6 to .Net Core 2.0. When the crash occurs all 64 Cores are spiked at 100% CPU.
Example Call Stack:
dotnet/corefx#1: SafeWinHttpHandle.ReleaseHandle()
00 coreclr!EEPolicy::HandleFatalError
01 coreclr!ProcessCLRException
02 ntdll!RtlpExecuteHandlerForException
03 ntdll!RtlDispatchException
04 ntdll!KiUserExceptionDispatch
05 crypt32!ReleaseContextElement
06 crypt32!CertFreeCertificateContext
07 winhttp!WEBIO_REQUEST::{dtor}
08 winhttp!WEBIO_REQUEST::`scalar deleting destructor'
09 winhttp!HTTP_BASE_OBJECT::Dereference
0a winhttp!HTTP_USER_REQUEST::_SafeDetachSysReq
0b winhttp!HTTP_USER_REQUEST::Shutdown
0c winhttp!HTTP_REQUEST_HANDLE_OBJECT::SafeShutdownUsrReq
0d winhttp!_InternetCloseHandle
0e winhttp!WinHttpCloseHandle
Child SP IP Call Site
00000109e165da28 00007ffaf35a4f86 [InlinedCallFrame: 00000109e165da28] Interop+WinHttp.WinHttpCloseHandle(IntPtr)
00000109e165da28 00007ffa943ab463 [InlinedCallFrame: 00000109e165da28] Interop+WinHttp.WinHttpCloseHandle(IntPtr)
00000109e165dab0 00007ffaf1bb6b08 Interop+WinHttp+SafeWinHttpHandle.ReleaseHandle() [E:\A\_work\774\s\corefx\src\Common\src\Interop\Windows\winhttp\Interop.SafeWinHttpHandle.cs @ 59]
00000109e165dcd0 00007ffaf3482d33 [GCFrame: 00000109e165dcd0]
00000109e165dd08 00007ffaf3482d33 [GCFrame: 00000109e165dd08]
00000109e165de58 00007ffaf3482d33 [HelperMethodFrame_1OBJ: 00000109e165de58] System.Runtime.InteropServices.SafeHandle.InternalDispose()
00000109e165dfc0 00007ffaf1bd1ca7 System.Net.Http.WinHttpResponseStream.Dispose(Boolean) [E:\A\_work\774\s\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpResponseStream.cs @ 282]
00000109e165e000 00007ffaf2e1a72a System.IO.Stream.Close() [E:\A\_work\308\s\src\mscorlib\src\System\IO\Stream.cs @ 263]
00000109e165e030 00007ffaf1bc97d0 System.Net.Http.NoWriteNoSeekStreamContent+c.b__4_0(System.Threading.Tasks.Task, System.Object) [E:\A\_work\774\s\corefx\src\Common\src\System\Net\Http\NoWriteNoSeekStreamContent.cs @ 51]
00000109e165e070 00007ffaf2d871ce System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [E:\A\_work\308\s\src\mscorlib\shared\System\Threading\ExecutionContext.cs @ 145]
00000109e165e0e0 00007ffaf2e143d6 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\Task.cs @ 2454]
00000109e165e180 00007ffaf2f78446 System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task, Boolean) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\ThreadPoolTaskScheduler.cs @ 76]
00000109e165e1d0 00007ffaf2e439b3 System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task, Boolean) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\TaskScheduler.cs @ 210]
00000109e165e230 00007ffaf2e800df System.Threading.Tasks.TaskContinuation.InlineIfPossibleOrElseQueue(System.Threading.Tasks.Task, Boolean) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\TaskContinuation.cs @ 256]
00000109e165e280 00007ffaf2e155af System.Threading.Tasks.Task.RunContinuations(System.Object) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\Task.cs @ 3263]
00000109e165e370 00007ffaf2e81705 System.Threading.Tasks.Task`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].TrySetResult(System.Threading.Tasks.VoidTaskResult) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\future.cs @ 425]
00000109e165e3b0 00007ffaf2e5dc89 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult) [E:\A\_work\308\s\src\mscorlib\src\System\Runtime\CompilerServices\AsyncMethodBuilder.cs @ 605]
00000109e165e3f0 00007ffaf2e5dc1c System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].SetResult(System.Threading.Tasks.Task`1) [E:\A\_work\308\s\src\mscorlib\src\System\Runtime\CompilerServices\AsyncMethodBuilder.cs @ 646]
00000109e165e420 00007ffaf1bd2532 System.Net.Http.WinHttpResponseStream+d__18.MoveNext() [E:\A\_work\774\s\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpResponseStream.cs @ 163]
00000109e165e4e0 00007ffaf2d871ce System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [E:\A\_work\308\s\src\mscorlib\shared\System\Threading\ExecutionContext.cs @ 145]
00000109e165e550 00007ffaf2d871ce System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [E:\A\_work\308\s\src\mscorlib\shared\System\Threading\ExecutionContext.cs @ 145]
00000109e165e5c0 00007ffaf2e143d6 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) [E:\A\_work\308\s\src\mscorlib\src\System\Threading\Tasks\Task.cs @ 2454]
00000109e165e660 00007ffaf2e537f9 System.Threading.ThreadPoolWorkQueue.Dispatch() [E:\A\_work\308\s\src\mscorlib\src\System\Threading\ThreadPool.cs @ 582]
dotnet/corefx#2: SafeWinHttpHandle.ReleaseHandle()
Child SP IP Call Site
000000bb26d9c590 00007ffd81220c8a [FaultingExceptionFrame: 000000bb26d9c590]
000000bb26d9ca90 00007ffd6754e6c6 System.Net.Http.WinHttpRequestCallback.RequestCallback(IntPtr, System.Net.Http.WinHttpRequestState, UInt32, IntPtr, UInt32)
000000bb26d9ea70 00007ffd68903190 [FaultingExceptionFrame: 000000bb26d9ea70]
000000bb26d9ef70 00007ffd6754e57e System.Net.Http.WinHttpRequestCallback.RequestCallback(IntPtr, System.Net.Http.WinHttpRequestState, UInt32, IntPtr, UInt32)
000000bb26d9efe0 00007ffd6754e4a7 System.Net.Http.WinHttpRequestCallback.WinHttpCallback(IntPtr, IntPtr, UInt32, IntPtr, UInt32)
000000bb26d9f030 00007ffd099b1332 DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int32, Int64, Int32)
000000bb26d9f2c8 00007ffd68a02e4a [InlinedCallFrame: 000000bb26d9f2c8] Interop+WinHttp.WinHttpCloseHandle(IntPtr)
000000bb26d9f2c8 00007ffd099b34c3 [InlinedCallFrame: 000000bb26d9f2c8] Interop+WinHttp.WinHttpCloseHandle(IntPtr)
000000bb26d9f350 00007ffd67536b08 Interop+WinHttp+SafeWinHttpHandle.ReleaseHandle()
000000bb26d9f4a0 00007ffd68a02d33 [GCFrame: 000000bb26d9f4a0]
000000bb26d9f618 00007ffd68a02d33 [GCFrame: 000000bb26d9f618]
000000bb26d9f6b8 00007ffd68a02d33 [HelperMethodFrame_1OBJ: 000000bb26d9f6b8] System.Runtime.InteropServices.SafeHandle.InternalFinalize()
000000bb26d9f7c0 00007ffd68359b16 System.Runtime.InteropServices.SafeHandle.Finalize()
000000bb26d9fbf0 00007ffd68a02ca6 [DebuggerU2MCatchHandlerFrame: 000000bb26d9fbf0]
dotnet/corefx#3: WinHttpHandler.HandleAsyncException ()
Exception object: 000000f740eb92f8
Exception type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
InnerException: <none>
StackTrace (generated):
System.Net.Http.WinHttpHandler.HandleAsyncException(System.Net.Http.WinHttpRequestState, System.Exception)
System_Net_Http!System.Net.Http.WinHttpHandler+<StartRequest>d__105.MoveNext()+
System_Private_CoreLib!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()System_Private_CoreLib!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
System_Private_CoreLib!System.Threading.ThreadPoolWorkQueue.Dispatch()
Thread Id: 1273 OS Id: 5be0 Locks: 0
Thread is Alive
Last Exception: (System.ExecutionEngineException) (null)
0000000cbaf6deb8 0000000000000000 InlinedCallFrame
0000000cbaf6deb8 0000000000000000 InlinedCallFrame
0000000cbaf6de90 00007ffbd2ac41b3 DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr)
0000000cbaf6df40 00007ffc31906768 Interop+WinHttp+SafeWinHttpHandle.ReleaseHandle()
0000000cbaf6e160 0000000000000000 GCFrame
0000000cbaf6e198 0000000000000000 GCFrame
0000000cbaf6e2e8 0000000000000000 HelperMethodFrame_1OBJ
0000000cbaf6e450 00007ffc31921767 System.Net.Http.WinHttpResponseStream.Dispose(Boolean)
0000000cbaf6e490 00007ffc2dcd009a System.IO.Stream.Close()
0000000cbaf6e4c0 00007ffc31919310 System.Net.Http.NoWriteNoSeekStreamContent+<>c.<SerializeToStreamAsync>b__4_0(System.Threading.Tasks.Task, System.Object)
0000000cbaf6e500 00007ffc2dc3b3be System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000cbaf6e570 00007ffc2dcc9d46 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
0000000cbaf6e610 00007ffc2de2c466 System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task, Boolean)
0000000cbaf6e660 00007ffc2dcf7213 System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task, Boolean)
0000000cbaf6e6c0 00007ffc2dd33a5f System.Threading.Tasks.TaskContinuation.InlineIfPossibleOrElseQueue(System.Threading.Tasks.Task, Boolean)
0000000cbaf6e710 00007ffc2dccaf1f System.Threading.Tasks.Task.RunContinuations(System.Object)
0000000cbaf6e800 00007ffc2dd35085 System.Threading.Tasks.Task`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].TrySetResult(System.Threading.Tasks.VoidTaskResult)
0000000cbaf6e840 00007ffc2dd114f9 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult)
0000000cbaf6e880 00007ffc2dd1148c System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib]].SetResult(System.Threading.Tasks.Task`1<System.Threading.Tasks.VoidTaskResult>)
0000000cbaf6e8b0 00007ffc31921fc6 System.Net.Http.WinHttpResponseStream+<CopyToAsyncCore>d__18.MoveNext()
0000000cbaf6e970 00007ffc2dc3b3be System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000cbaf6e9e0 00007ffc2dc3b3be System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000cbaf6ea50 00007ffc2dcc9d46 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
0000000cbaf6eaf0 00007ffc2dd07069 System.Threading.ThreadPoolWorkQueue.Dispatch()
Some Notes on the usage of HttpClient
:
- Shared instance of
HttpClientHandler
asstatic readonly HttpMessageHandler
- Most often invoked methods:
public object Invoke(string method, Type returnType = null, object parameters = null)
public async Task<object> InvokeAsync(string method, Type returnType = null, object parameters = null, CancellationToken cancellationToken = default (CancellationToken))
- The core functionality is implemented by
async Task<object> GetResponseAsync
- Instantiates new instance of
HttpClient
on every call as newHttpClient(webServerInvoker.Handler, false)
wherewebServerInvoker.Handler
is the shared static instance. - Awaits for
PostAsync
result, a timedCancellationToken
is provided . - Always disposes
HttpClient
instance at the end of the call. - Note that synchronous public object Invoke enforces its own timeout while waiting for InvokeAsync Task result. It cancels the CancellationTokenSource if the timeout is hit, in turn cancelling any pending HttpClient operation and immediately disposing of HttpClient instance.
- The timeout is provided by the caller. It ranges from 30 seconds to 5 minutes.
[EDIT] Formatting changes by @karelz
Metadata
Metadata
Assignees
Labels
area-System.Net.Httpbugtenet-reliabilityReliability/stability related issue (stress, load problems, etc.)Reliability/stability related issue (stress, load problems, etc.)