FlameGraph icon indicating copy to clipboard operation
FlameGraph copied to clipboard

Consider stripping null byte in frame name

Open Krinkle opened this issue 2 years ago • 0 comments

This came up downstream in Wikimedia's PHP profiling stack (https://performance.wikimedia.org/php-profiling/, https://phabricator.wikimedia.org/T273640) where some of the collected samples were formatted using a null byte.

This is how PHP 7.2 represents an unnamed lamba, by joining the surrounding class name with "anonymous" and the defining file's path.

class@anonymous\0/srv/mediawiki/1.36.0-wmf.27/extensions/CirrusSearch/includes/CirrusSearch.php0x7fbdf64f0551::parse 1

Which resulted in the output SVG not rendering well in the browser, due to:

This page contains the following errors:
error on line 2012 at column 23: Char 0x0 out of allowed range
Below is a rendering of the page up to the first error.

We've fixed the producer on our end (as we should have, either way). It may be useful to strip directly in flamegraph.pl if you think its seems probable for other consumers to run into this (if they also instrument PHP and/or from other sources), and if it seems reasonable for such byte to exist in a tracelog file that is otherwise collapsed and well-formatted. I don't mind either way. Thanks for the tool!

Krinkle avatar Apr 05 '22 01:04 Krinkle