JuliaLang/julia

Why do StackFrame comparisons and hash ignore linfo?

Open

#47,028 opened on Oct 3, 2022

View on GitHub
 (0 comments) (2 reactions) (0 assignees)Julia (5,773 forks)batch import
bugequalityhelp wanted

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

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!

Contributor guide