JuliaLang/julia

Why do StackFrame comparisons and hash ignore linfo?

开放

#47,028 创建于 2022年10月3日

 (0 条评论) (2 个反应) (0 位负责人)Julia (5,773 个派生)batch import
bugequalityhelp wanted

仓库指标

星标
 (48,709 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

We were seeing bugs in PProf's conversion from stack traces (Vector{StackFrame}) to PProf protos, and we eventually tracked the issue down to this:

Aha! It turns out it's because comparing StackFrames apparently skips the linfo and pointer, even though apparently also sometimes a StackFrame can be empty other than the linfo and pointer!!! 😮 https://github.com/JuliaLang/julia/blob/00646634c6a73998eaae3785eb78fea881c39502/base/stacktraces.jl#L80-L96

And indeed, in this case:

julia> fr1.func, fr1.line, fr1.file, fr1.inlined
(Symbol(""), -1, Symbol(""), false)

julia> fr3.func, fr3.line, fr3.file, fr3.inlined
(Symbol(""), -1, Symbol(""), false)

(I'm not sure why that stuff is all missing!?)

Originally posted by @NHDaly in https://github.com/JuliaPerf/PProf.jl/issues/69#issuecomment-1264461763

So, two questions, I guess:

  1. Do you know why it's possible for all the other fields of a StackTrace to be not present, even when it's not inlined?
  2. Given that the above is possible, why do we ignore the linfo for the hash and == comparisons? Is it a perf optimization?
    • and follow-up: what about the .pointer field?

thanks!

贡献者指南