Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quotes in CPU profile tags not escaped properly #769

Open
tbg opened this issue Apr 14, 2023 · 1 comment
Open

quotes in CPU profile tags not escaped properly #769

tbg opened this issue Apr 14, 2023 · 1 comment
Labels
Priority: p3 Buganizer priority - P3 type: bug Buganizer type - Bug

Comments

@tbg
Copy link
Contributor

tbg commented Apr 14, 2023

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"]

pprof.pb.gz.txt
pprof.dot.txt

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:

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.

Footnotes

  1. https://github.com/google/pprof/blob/a41b82acbcb1f6a6d0998b0fddeb1f1adb7d8fc1/internal/graph/dotgraph.go#L490-L495

@tbg tbg changed the title quotes in CPU profile tags not ecsaped properly quotes in CPU profile tags not escaped properly Apr 14, 2023
@Louis-Ye Louis-Ye added type: bug Buganizer type - Bug Priority: p3 Buganizer priority - P3 labels May 12, 2023
@D3Hunter
Copy link

D3Hunter commented Feb 20, 2024

the err i met is:

Warning: syntax ambiguity - badly delimited number '0.01s' in line 8 of <stdin> splits into two tokens
Error: <stdin>: syntax error in line 8 near 's'

dot content like:

N1_2 [label = "plan_digest:)HJøì³;×!ªÚ*eçwÑw^?½ïªC<9f>^_;Î:zEi<8f>«\nsql_digest:^T^YÜ?B<9d>8ªc<V~<9a>s<82>Ä^E^@$6yߧ~<81>¨ãì¹Cnâ" id="N1_2" fontsize=8 shape=box3d tooltip="0.01s"]

workaround that works for me cockroachdb/cockroach#101523 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: p3 Buganizer priority - P3 type: bug Buganizer type - Bug
Projects
None yet
Development

No branches or pull requests

3 participants