-
Notifications
You must be signed in to change notification settings - Fork 641
Description
What version of pprof are you using?
00490a6 (i.e. main as of today), but the problem exists in all prior versions. I first stumbled upon it in Go 1.19.
What operating system and processor architecture are you using?
Irrelevant
What did you do?
Run pprof -dot on the provided file (this is a CPU profile taken of a CockroachDB 23.1 node, but these details don't matter). Note how the resulting .dot file is invalid since the " occurring in a label was not properly escaped:
N36_0 [label = "range_str:12419/2:/Table/136/1/"{NHCH-…-PWN-a"}" id="N36_0" fontsize=8 shape=box3d tooltip="0.01s"]
What did you expect to see?
The " in the label should have been escaped, resulting in a valid .dot file.
What did you see instead?
An invalid dot file, which in particular implies that the graph view in pprof isn't working. The line above should have been
N36_0 [label = "range_str:12419/2:/Table/136/1/\"{NHCH-…-PWN-a\"}" id="N36_0" fontsize=8 shape=box3d tooltip="0.01s"]
which would work.
I gave it a half-hearted attempt at fixing, but it seemed like there might be more than one place where the escaping isn't happening properly and it wasn't super clear to me where we'd need to throw in an escapeForDot1 on top of here:
pprof/internal/graph/dotgraph.go
Line 251 in a41b82a
| nodelets += fmt.Sprintf(`N%d -> N%d_%d [label=" %s" weight=100 tooltip="%s" labeltooltip="%s"]`+"\n", nodeID, nodeID, i, weight, weight, weight) |
Also, it seems useful to add testing for these sorts of things.