Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #19655 (TypeError on empty stacktrace) #19656

Merged
merged 2 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ doesn't return C functions, but this can be enabled.) When called without specif
trace, `stacktrace` first calls `backtrace`.
"""
function stacktrace(trace::Vector{Ptr{Void}}, c_funcs::Bool=false)
stack = vcat(map(lookup, trace)...)::StackTrace
stack = vcat(StackTrace(), map(lookup, trace)...)::StackTrace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would: StackTrace[ lookup(x) for x in trace ] make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't concatenate the results of lookup together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially a "flatten" operation.


# Remove frames that come from C calls.
if !c_funcs
Expand Down
9 changes: 9 additions & 0 deletions test/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@ let ctestptr = cglobal((:ctest, "libccalltest")),
@test ctest[1].from_c
@test ctest[1].pointer === UInt64(ctestptr)
end

# #19655
let
# not in a `catch`, so should return an empty StackTrace
st = stacktrace(empty!(backtrace()))

@test isempty(st)
@test isa(st, StackTrace)
end