Skip to content

Commit

Permalink
Remove from_c caller frames from depwarn attribution
Browse files Browse the repository at this point in the history
Fixes #25130
  • Loading branch information
c42f committed Dec 18, 2017
1 parent 1b01101 commit 16bdf88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function firstcaller(bt::Vector, funcsyms)
for frame in bt
lkups = StackTraces.lookup(frame)
for outer lkup in lkups
if lkup == StackTraces.UNKNOWN
if lkup == StackTraces.UNKNOWN || lkup.from_c
continue
end
if found
Expand Down
18 changes: 18 additions & 0 deletions test/deprecation_exec.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test
using Logging

module DeprecationTests # to test @deprecate
f() = true
Expand Down Expand Up @@ -81,3 +82,20 @@ depwarn24658() = Base.firstcaller(backtrace(), :_func_not_found_)
# issue #24658
@test eval(:(if true; f24658(); end)) == (Ptr{Void}(0),StackTraces.UNKNOWN)
end

# issue #25130
f25130() = Base.depwarn("f25130 message", :f25130)
# The following test is for the depwarn behavior of expressions evaluated at
# top-level, so we can't use the usual `collect_test_logs()` / `with_logger()`
testlogger = Test.TestLogger()
prev_logger = global_logger(testlogger)
# Each call at top level should be distinct. This won't be true if they're
# attributed to internal C frames (including generic dispatch machinery)
f25130()
f25130()
testlogs = testlogger.logs
@test length(testlogs) == 2
@test testlogs[1].id != testlogs[2].id
@test testlogs[1].kwargs.caller.func == Symbol("top-level scope")
@test all(l.message == "f25130 message" for l in testlogs)
global_logger(prev_logger)

0 comments on commit 16bdf88

Please sign in to comment.