From f1e33bd64a6e3c04d6105e2cbc28cb2ecab661f6 Mon Sep 17 00:00:00 2001 From: fredcallaway Date: Fri, 16 Jul 2021 16:50:58 -0700 Subject: [PATCH 1/2] while loop -> for loop in _simplify_include_frames (fixes #41566) prevents the possibility of a bounds error when i = 0 --- base/errorshow.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/base/errorshow.jl b/base/errorshow.jl index 641cf5f2cdf4b..c93e5733b21b7 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -773,10 +773,9 @@ end # For improved user experience, filter out frames for include() implementation # - see #33065. See also #35371 for extended discussion of internal frames. function _simplify_include_frames(trace) - i = length(trace) - kept_frames = trues(i) + kept_frames = trues(length(trace)) first_ignored = nothing - while i >= 1 + for i in length(trace):-1:1 frame::StackFrame, _ = trace[i] mod = parentmodule(frame) if first_ignored === nothing @@ -801,7 +800,7 @@ function _simplify_include_frames(trace) i -= 1 end if first_ignored !== nothing - kept_frames[i:first_ignored] .= false + kept_frames[1:first_ignored] .= false end return trace[kept_frames] end From 85ba3c232e62f14c0fe32966ce1b9123456f5e8a Mon Sep 17 00:00:00 2001 From: Fred Callaway Date: Fri, 16 Jul 2021 17:58:18 -0700 Subject: [PATCH 2/2] Remove spurious i -= 1 Co-authored-by: Thomas Christensen --- base/errorshow.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/base/errorshow.jl b/base/errorshow.jl index c93e5733b21b7..6cd94cbed371a 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -797,7 +797,6 @@ function _simplify_include_frames(trace) first_ignored = nothing end end - i -= 1 end if first_ignored !== nothing kept_frames[1:first_ignored] .= false