This example is from a Discourse [post](https://discourse.julialang.org/t/profil…er-timing-related-to-line-0/71033) that doesn't seem like it was ever turned into a bug report.
`/tmp/j.jl`:
```julia
function build_cov!(cov,μ,cx,cy,bimage,bism,Np,widx,widy)
Δx = (widx-1)÷2
Δy = (widy-1)÷2
halfNp = (Np-1) ÷ 2
Δr, Δc = cx-(halfNp+1), cy-(halfNp+1)
for dc=0:Np-1 # column shift loop
pcr = 1:Np-dc
for dr=1-Np:Np-1# row loop, incl negatives
if (dr < 0) & (dc == 0)
continue
end
if dr >= 0
prr = 1:Np-dr
end
if (dr < 0) & (dc > 0)
prr = 1-dr:Np
end
for pc=pcr, pr=prr
i = ((pc -1)*Np)+pr
j = ((pc+dc-1)*Np)+pr+dr
μ1μ2 = bimage[pr+Δr,pc+Δc]*bimage[pr+dr+Δr,pc+dc+Δc]/((widx*widy)^2)
cov[i,j] = bism[pr+Δr,pc+Δc,dr+Np,dc+1]/(widx*widy) - μ1μ2
if i == j
μ[i] = μ1μ2
end
end
end
end
cov .*= (widx*widy)/((widx*widy)-1)
return
end
cx=100
cy=100
Np = 33
cov = zeros(Np*Np,Np*Np)
μ = zeros(Np*Np)
bimage=rand(200,400)
bism=rand(200,400,2*Np-1, Np)
widx = 13
widy = 13
build_cov!(cov,μ,cx,cy,bimage,bism,Np,widx,widy)
import Profile
Profile.init(n=10^7,delay=1e-5)
const opt_checked = Val(:checked)
const opt_unchecked = Val(:unchecked)
Profile.@profile build_cov!(cov,μ,cx,cy,bimage,bism,Np,widx,widy)
Profile.clear()
```
REPL:
```julia-repl
julia> include("/tmp/j.jl")
julia> Profile.@profile build_cov!(cov,μ,cx,cy,bimage,bism,Np,widx,widy)
julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
╎549 @Base/client.jl:543; _start()
╎ 549 @Base/client.jl:569; repl_main
╎ 549 @Base/client.jl:432; run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
╎ 549 @Base/essentials.jl:1027; invokelatest
╎ 549 @Base/essentials.jl:1030; #invokelatest#2
╎ 549 @Base/client.jl:448; (::Base.var"#1130#1132"{Bool, Symbol, Bool})(REPL::Module)
╎ ╎ 549 …i4-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:453; run_repl(repl::REPL.AbstractREPL, consumer::Any)
╎ ╎ 549 …4-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:467; run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
╎ ╎ 549 …4-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:308; kwcall(::NamedTuple, ::typeof(REPL.start_repl_backend), backend::REPL.REPLBackend, consumer::Any)
╎ ╎ 549 …-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:311; start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
╎ ╎ 549 …-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:326; repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
╎ ╎ ╎ 549 …-5/julialang/julia-master/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:229; eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
2╎ ╎ ╎ 549 @Base/boot.jl:428; eval
2╎ ╎ ╎ 2 @Base/abstractarray.jl:0; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
289╎ ╎ ╎ 289 /tmp/j.jl:0; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
╎ ╎ ╎ 11 /tmp/j.jl:22; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
╎ ╎ ╎ 11 @Base/array.jl:923; getindex
5╎ ╎ ╎ 11 @Base/abstractarray.jl:699; checkbounds
╎ ╎ ╎ ╎ 6 @Base/abstractarray.jl:681; checkbounds
╎ ╎ ╎ ╎ 6 @Base/abstractarray.jl:725; checkbounds_indices
╎ ╎ ╎ ╎ 6 @Base/abstractarray.jl:754; checkindex
6╎ ╎ ╎ ╎ 6 @Base/int.jl:513; <
╎ ╎ ╎ 112 /tmp/j.jl:23; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
1╎ ╎ ╎ 1 @Base/abstractarray.jl:0; setindex!
╎ ╎ ╎ 3 @Base/array.jl:923; getindex
3╎ ╎ ╎ 3 @Base/abstractarray.jl:697; checkbounds
╎ ╎ ╎ 64 @Base/array.jl:924; getindex
64╎ ╎ ╎ 64 @Base/essentials.jl:892; getindex
╎ ╎ ╎ 7 @Base/array.jl:987; setindex!
3╎ ╎ ╎ 3 @Base/abstractarray.jl:0; checkbounds
4╎ ╎ ╎ 4 @Base/abstractarray.jl:699; checkbounds
12╎ ╎ ╎ 12 @Base/array.jl:988; setindex!
21╎ ╎ ╎ 21 @Base/float.jl:479; -
╎ ╎ ╎ 4 @Base/promotion.jl:428; /
4╎ ╎ ╎ 4 @Base/float.jl:481; /
╎ ╎ ╎ 26 /tmp/j.jl:24; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
25╎ ╎ ╎ 26 @Base/promotion.jl:635; ==
1╎ ╎ ╎ 2 /tmp/j.jl:27; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
╎ ╎ ╎ 1 @Base/range.jl:908; iterate
1╎ ╎ ╎ 1 @Base/promotion.jl:635; ==
╎ ╎ ╎ 105 /tmp/j.jl:30; build_cov!(cov::Matrix{Float64}, μ::Vector{Float64}, cx::Int64, cy::Int64, bimage::Matrix{Float64}, bism::Array{Float64, 4}, Np::Int64, widx::Int64, widy::Int64)
╎ ╎ ╎ 105 @Base/broadcast.jl:875; materialize!
╎ ╎ ╎ 105 @Base/broadcast.jl:878; materialize!
╎ ╎ ╎ ╎ 105 @Base/broadcast.jl:920; copyto!
╎ ╎ ╎ ╎ 105 @Base/broadcast.jl:967; copyto!
╎ ╎ ╎ ╎ 105 @Base/simdloop.jl:77; macro expansion
╎ ╎ ╎ ╎ 105 @Base/broadcast.jl:968; macro expansion
╎ ╎ ╎ ╎ 80 @Base/broadcast.jl:605; getindex
╎ ╎ ╎ ╎ ╎ 1 @Base/broadcast.jl:645; _broadcast_getindex
╎ ╎ ╎ ╎ ╎ 1 @Base/broadcast.jl:669; _getindex
╎ ╎ ╎ ╎ ╎ 1 @Base/broadcast.jl:639; _broadcast_getindex
╎ ╎ ╎ ╎ ╎ 1 @Base/multidimensional.jl:700; getindex
╎ ╎ ╎ ╎ ╎ 1 @Base/array.jl:924; getindex
╎ ╎ ╎ ╎ ╎ ╎ 1 @Base/abstractarray.jl:1371; _to_linear_index
╎ ╎ ╎ ╎ ╎ ╎ 1 @Base/abstractarray.jl:3081; _sub2ind
╎ ╎ ╎ ╎ ╎ ╎ 1 @Base/abstractarray.jl:3097; _sub2ind
╎ ╎ ╎ ╎ ╎ ╎ 1 @Base/abstractarray.jl:3113; _sub2ind_recurse
1╎ ╎ ╎ ╎ ╎ ╎ 1 @Base/int.jl:87; +
╎ ╎ ╎ ╎ ╎ 79 @Base/broadcast.jl:646; _broadcast_getindex
╎ ╎ ╎ ╎ ╎ 79 @Base/broadcast.jl:673; _broadcast_getindex_evalf
79╎ ╎ ╎ ╎ ╎ 79 @Base/float.jl:480; *
╎ ╎ ╎ ╎ 25 @Base/multidimensional.jl:702; setindex!
25╎ ╎ ╎ ╎ ╎ 25 @Base/array.jl:988; setindex!
Total snapshots: 549. Utilization: 100% across all threads and tasks. Use the `groupby` kwarg to break down by thread and/or task.
julia> versioninfo()
Julia Version 1.12.0-DEV.162
Commit 5c7d24493eb (2024-03-09 22:22 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
```
Several things in the profiler output seem wrong:
1. Some line numbers are zero
2. The entry `549 @Base/boot.jl:428; eval` has `2 @Base/abstractarray.jl:0; build_cov!` as a (direct) child, seems like an incomplete stack trace, that is, some intermediate entries are missing
3. The entry `2 @Base/abstractarray.jl:0; build_cov!` is nonsensical because there is no `build_cov!` in `abstractarray.jl`
Perhaps some of the malformed entries are related to bounds checking?