You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Unhandled exceptions cause assert / crash Unix #1867
On Windows, both software and hardware unhandled exception causes assert in StackFrameIterator::NextInternal: ASSERT(m_pInstance->FindCodeManagerByAddress(m_ControlPC));
The m_ControlPC points to a code inside the wmain function, which doesn't belong to any of the registered modules.
On Unix, it ends up in an infinite loop in EH.DispatchEx calling RhpSfiNext and getting stuck at Exceptions_BringUpTest__Main for unhandled software exception and it fails with SIGSEGV for any hardware unhandled exception.
I believe a variant of this bug also occurs on Unix when a P/Invoked function calls back from the native world to a managed function, in which you have a try/catch block spanning the entire method that should handle all exceptions, yet it still gets stuck at the infinite loop in EH.DispatchEx as mentioned above.
Pseudocode:
SomePInvokeFunction(AddrOfIntrinsics.AddrOf(new Action(Callback)));
void Callback()
{
try {
throw new Exception("test");
} catch (Exception e)
{
//We don't go here, but to the infinite loop
}
}
changed the title [-]Unhandled exceptions cause assert / crash on Windows / Unix[/-][+]Unhandled exceptions cause assert / crash Unix[/+]on Nov 8, 2016
We need unwinder that keeps track of where everything is stored. Statically linking customized version of LLVM's libuwind seems to be the best solution for it.
The quick fix to stop EH from crashing would be to add UIntNative FP to REGDISPLAY for Unix or MacOS; get/set it in UnwindCursorToRegDisplay/RegDisplayToUnwindCursor to UNW_X86_64_RBP; and return it from GetFP() instead *pRbp. @christianscheuer Would you like to give it a shot?
Activity
jkotas commentedon Sep 19, 2016
This bug is caused by this TODO in
*CodeManager::UnwindStackFrame:christianscheuer commentedon Oct 6, 2016
I believe a variant of this bug also occurs on Unix when a P/Invoked function calls back from the native world to a managed function, in which you have a try/catch block spanning the entire method that should handle all exceptions, yet it still gets stuck at the infinite loop in EH.DispatchEx as mentioned above.
Pseudocode:
[-]Unhandled exceptions cause assert / crash on Windows / Unix[/-][+]Unhandled exceptions cause assert / crash Unix[/+]jkotas commentedon Nov 8, 2016
The remaining issue is Segmentation Fault at:
We need unwinder that keeps track of where everything is stored. Statically linking customized version of LLVM's libuwind seems to be the best solution for it.
christianscheuer commentedon Nov 8, 2016
@jkotas Would there be any workaround for letting exceptions fail more gracefully / not crash the process, until this is resolved?
jkotas commentedon Nov 8, 2016
The quick fix to stop EH from crashing would be to add
UIntNative FPto REGDISPLAY for Unix or MacOS; get/set it inUnwindCursorToRegDisplay/RegDisplayToUnwindCursorto UNW_X86_64_RBP; and return it from GetFP() instead*pRbp. @christianscheuer Would you like to give it a shot?christianscheuer commentedon Nov 8, 2016
@jkotas thanks! That would be my pleasure :)
MichalStrehovsky commentedon Jun 10, 2017
Unhandled exceptions now work on Unix.