From: Zoltan Varga Date: Tue, 5 Jan 2021 15:46:28 +0000 (-0500) Subject: Avoid an exception in Exception.GetCaptureState() if the stack trace is empty, it... X-Git-Tag: submit/tizen/20210909.063632~3949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c13a9ddf4ef99bbce83acb66f6b3d8943d99214;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Avoid an exception in Exception.GetCaptureState() if the stack trace is empty, it can happen on wasm+aot. (#46539) --- 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) {