Description
I stumbled upon astack overflow exception crash dump which doesn't obviously have user code in the stack, and passes through AsyncStreamReader.FlushMessageQueue(Boolean), which was introduced in a refactoring of AsyncStreamReader that also seems to have introduced this concept of 'rethrowInNewThread', where the exception will be raised on a diferent thread from the calling one, for some reason.
bool [FlushMessageQueue](https://source.dot.net/System.Diagnostics.Process/R/db4c3f24df1043ec.html)(bool rethrowInNewThread)
|
private bool FlushMessageQueue(bool rethrowInNewThread) |
I'm not sure if I understand how the stack overflow exception originally arose here. However, as I think about this code, it seems to me that the design of this is kind of inherently flawed, because 'rethrowInNewThread' is trying to rethrow fatal stack overflow exceptions on a different worker thread, even though they are really fatal exceptions about corrupt state on the current thread.
App!out_of_memory+0x0
unknown![.ecxr]+0x0
ntdll!RtlReportSilentProcessExit+0x0 [minkernel\ntdll\wer.c @ 2501]
KERNELBASE!TerminateProcess+0x0 [minkernel\kernelbase\process.c @ 3689]
KERNELBASE!RaiseFailFastException+0x0 [minkernel\kernelbase\xcpt.c @ 1224]
coreclr!WatsonLastChance+0x0 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 3842]
coreclr!EEPolicy::HandleFatalStackOverflow+0x0 [D:\a\_work\1\s\src\coreclr\vm\eepolicy.cpp @ 726]
coreclr!EEPolicy::HandleStackOverflow+0x0 [D:\a\_work\1\s\src\coreclr\vm\eepolicy.cpp @ 147]
coreclr!CLRException::HandlerState::SetupCatch+0x0 [D:\a\_work\1\s\src\coreclr\vm\clrex.cpp @ 878]
coreclr!`TieredCompilationManager::CreateBackgroundWorker'::`1'::catch$15+0x0 [D:\a\_work\1\s\src\coreclr\vm\tieredcompilation.cpp @ 375]
coreclr!_CallSettingFrame_LookupContinuationIndex+0x0 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 98]
coreclr!__FrameHandler4::CxxCallCatchBlock+0x0 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1393]
ntdll!RcFrameConsolidation+0x0 [minkernel\ntos\rtl\amd64\capture.asm @ 1124]
coreclr!TieredCompilationManager::CreateBackgroundWorker+0x0 [D:\a\_work\1\s\src\coreclr\vm\tieredcompilation.cpp @ 367]
coreclr!TieredCompilationManager::HandleCallCountingForFirstCall+0x0 [D:\a\_work\1\s\src\coreclr\vm\tieredcompilation.cpp @ 182]
coreclr!CodeVersionManager::PublishVersionableCodeIfNecessary+0x0 [D:\a\_work\1\s\src\coreclr\vm\codeversion.cpp @ 1861]
coreclr!MethodDesc::DoPrestub+0x0 [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp @ 2215]
coreclr!PreStubWorker+0x0 [D:\a\_work\1\s\src\coreclr\vm\prestub.cpp @ 2039]
coreclr!ThePreStub+0x0
System_Diagnostics_Process!System.Diagnostics.AsyncStreamReader.FlushMessageQueue(Boolean)+0x0 [/_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/AsyncStreamReader.cs @ 224]
unknown!noop+0x0 [/_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/AsyncStreamReader.cs @ 95]
System_Private_CoreLib!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 158]
unknown!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[System.Diagnostics.AsyncStreamReader+_ReadBufferAsync_d__16, System.Diagnostics.Process]].MoveNext(System.Thre+0x0
System_Private_CoreLib!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs @ 765]
System_Private_CoreLib!System.Threading.Tasks.Task.RunContinuations(System.Object)+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 3358]
unknown!System.Threading.Tasks.Task`1[[System.Int32, System.Private.CoreLib]].TrySetResult(Int32)+0x0
System_Private_CoreLib!System.IO.Strategies.BufferedFileStreamStrategy+_ReadFromNonSeekableAsync_d__36.MoveNext()+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/BufferedFileStreamStrategy.cs @ 376]
System_Private_CoreLib!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 158]
unknown!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Int32, System.Private.CoreLib],[System.IO.Strategies.BufferedFileStreamStrategy+_ReadFromNonSeekableAsync_d__36, System.Private.CoreLib]].MoveNext(System.Threading.Thr+0x0
System_Private_CoreLib!Microsoft.Win32.SafeHandles.SafeFileHandle+ThreadPoolValueTaskSource.ExecuteInternal+0x0 [/_/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.ThreadPoolValueTaskSource.cs @ 151]
System_Private_CoreLib!Microsoft.Win32.SafeHandles.SafeFileHandle+ThreadPoolValueTaskSource.System.Threading.IThreadPoolWorkItem.Execute+0x0 [/_/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.ThreadPoolValueTaskSource.cs @ 163]
System_Private_CoreLib!System.Threading.ThreadPoolWorkQueue.Dispatch()+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @ 613]
System_Private_CoreLib!System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart+0x0 [/_/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs @ 63]
System_Private_CoreLib!System.Threading.Thread.StartCallback+0x0 [/_/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @ 106]
coreclr!CallDescrWorkerInternal+0x0
coreclr!DispatchCallSimple+0x0 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp @ 220]
coreclr!ThreadNative::KickOffThread_Worker+0x0 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 158]
coreclr!ManagedThreadBase_DispatchMiddle+0x0 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7365]
coreclr!ManagedThreadBase_DispatchOuter+0x0 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7524]
coreclr!ThreadNative::KickOffThread+0x0 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 230]
kernel32!BaseThreadInitThunk+0x0 [clientcore\base\win32\client\thread.c @ 75]
ntdll!RtlUserThreadStart+0x0 [minkernel\ntdll\rtlstrt.c @ 1152]
Reproduction Steps
Repro not yet know.
Expected behavior
Uncertain. App crash, with actionable stack?
Actual behavior
App crash, with mysterious stack
Regression?
Unknown if this is a regression from .Net Framework.
Known Workarounds
No response
Configuration
My current best guess is that this is running recent .Net 6 bits, on Windows Server x64 OS.
OSBuildString:
20348.859.amd64fre.fe_release_svc_prod2.220707-1832
Other information
No response
Description
I stumbled upon astack overflow exception crash dump which doesn't obviously have user code in the stack, and passes through
AsyncStreamReader.FlushMessageQueue(Boolean), which was introduced in a refactoring of AsyncStreamReader that also seems to have introduced this concept of 'rethrowInNewThread', where the exception will be raised on a diferent thread from the calling one, for some reason.bool [FlushMessageQueue](https://source.dot.net/System.Diagnostics.Process/R/db4c3f24df1043ec.html)(bool rethrowInNewThread)runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/AsyncStreamReader.cs
Line 214 in 634cc1e
I'm not sure if I understand how the stack overflow exception originally arose here. However, as I think about this code, it seems to me that the design of this is kind of inherently flawed, because 'rethrowInNewThread' is trying to rethrow fatal stack overflow exceptions on a different worker thread, even though they are really fatal exceptions about corrupt state on the current thread.
Reproduction Steps
Repro not yet know.
Expected behavior
Uncertain. App crash, with actionable stack?
Actual behavior
App crash, with mysterious stack
Regression?
Unknown if this is a regression from .Net Framework.
Known Workarounds
No response
Configuration
My current best guess is that this is running recent .Net 6 bits, on Windows Server x64 OS.
OSBuildString:
20348.859.amd64fre.fe_release_svc_prod2.220707-1832
Other information
No response