PProf.jl icon indicating copy to clipboard operation
PProf.jl copied to clipboard

PProf fails to build `dot` graph if name contains `"`

Open NHDaly opened this issue 5 years ago • 1 comments

For example:

julia> function var"#fo\"o#"()
           peakflops()
       end
#fo"o# (generic function with 1 method)

julia> var"#fo\"o#"()
1.8314014985396976e11

julia> Profile.clear()

julia> @profile var"#fo\"o#"()
1.7486120937946786e11

julia> pprof(out="var", webport=2232)
[ Info: Writing output to var.pb.gz
"var.pb.gz"

julia> Main binary filename not available.
Serving web UI on http://localhost:2232
Error: <stdin>: syntax error in line 39 near 'N37'
Failed to execute dot. Is Graphviz installed?
exit status 1
Error: <stdin>: syntax error in line 39 near 'N37'
Failed to execute dot. Is Graphviz installed?
exit status 1

By dumping the dot file, you can see the mistake: pprof itself is not escaping the name correctly:

julia> PProf.pprof_jll.pprof() do _
           io = IOBuffer()
           run(pipeline(`pprof -dot var.pb.gz`, stdout=io))
           write("profile.dot", String(take!(io)))
       end
N35 [label="LinearAlgebra\npeakflops##kw\n0 of 47 (47.00%)" id="node35" fontsize=8 shape=box tooltip="LinearAlgebra.peakflops##kw (47)" color="#b22400" fillcolor="#eddad5"]
N36 [label="Main\n#fo"o#\n0 of 47 (47.00%)" id="node36" fontsize=8 shape=box tooltip="Main.#fo"o# (47)" color="#b22400" fillcolor="#eddad5"]
N37 [label="REPL\n#run_repl#41\n0 of 47 (47.00%)" id="node37" fontsize=8 shape=box tooltip="REPL.#run_repl#41 (47)" color="#b22400" fillcolor="#eddad5"]

I'm going to open a PR against pprof to fix this. But if it stalls, we may want to escape the names we provide to the proto, but it's annoying because then they print ugly (and incorrectly) in the flamegraph

NHDaly avatar Oct 03 '20 04:10 NHDaly

I am running into this, with the error message

Error: <stdin>: syntax error in line 26 scanning a quoted string (missing endquote? longer than 16384?)
String starting:"Alloc: Vector{Tuple{@NamedTuple{M̂::ForwardDiff.Dual{ForwardDiff.Tag{Base.Fix1{
Failed to execute dot. Is Graphviz installed?
exit status 1

Could it be the unicode or the @? Or just that the line is crazily long?

tpapp avatar Dec 04 '25 13:12 tpapp