From 4c13a9ddf4ef99bbce83acb66f6b3d8943d99214 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 5 Jan 2021 10:46:28 -0500 Subject: [PATCH] Avoid an exception in Exception.GetCaptureState() if the stack trace is empty, it can happen on wasm+aot. (#46539) --- src/mono/netcore/System.Private.CoreLib/src/System/Exception.Mono.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Exception.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Exception.Mono.cs index dbe3dcb..8bd7cd6 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Exception.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Exception.Mono.cs @@ -75,7 +75,8 @@ namespace System if (_traceIPs != null) { stackFrames = Diagnostics.StackTrace.get_trace(this, 0, true); - stackFrames[stackFrames.Length - 1].isLastFrameFromForeignException = true; + if (stackFrames.Length > 0) + stackFrames[stackFrames.Length - 1].isLastFrameFromForeignException = true; if (foreignExceptionsFrames != null) { -- 2.7.4