Skip to content

Commit cfa2312

Browse files
iamed2tkelman
authored andcommitted
Fix #19655 (TypeError on empty stacktrace) (#19656)
* Fix #19655 * Test for #19655
1 parent 7648ad6 commit cfa2312

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

base/stacktraces.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ doesn't return C functions, but this can be enabled.) When called without specif
144144
trace, `stacktrace` first calls `backtrace`.
145145
"""
146146
function stacktrace(trace::Vector{Ptr{Void}}, c_funcs::Bool=false)
147-
stack = vcat(map(lookup, trace)...)::StackTrace
147+
stack = vcat(StackTrace(), map(lookup, trace)...)::StackTrace
148148

149149
# Remove frames that come from C calls.
150150
if !c_funcs

test/stacktraces.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,12 @@ let ctestptr = cglobal((:ctest, "libccalltest")),
124124
@test ctest[1].from_c
125125
@test ctest[1].pointer === UInt64(ctestptr)
126126
end
127+
128+
# #19655
129+
let
130+
# not in a `catch`, so should return an empty StackTrace
131+
st = stacktrace(empty!(backtrace()))
132+
133+
@test isempty(st)
134+
@test isa(st, StackTrace)
135+
end

0 commit comments

Comments
 (0)