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

Workaround #32 - fails parsing invalid utf8 dtrace output (macos only?) #101

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

michaelkirk
Copy link
Contributor

@michaelkirk michaelkirk commented Oct 2, 2020

Intermittently, invalid utf-8 is found in cargo-flamegraph.stacks, which causes parsing to blow up with the error:

unable to collapse generated profile data: Custom { kind: InvalidData, error: StringError("stream did not contain valid UTF-8") }

This commit doesn't fix the underlying problem, but simply works around
it by lossily re-encoding to valid utf8.

Anecdotally it seems to be macos symbol names at the end of the line that
contain the invalid utf-8 - I don't know if this is due to some error in dtrace
or if somehow the symbols actually contain non utf-8 encodings.

Note I did try explicitly specifying utf8 output, by adding to the
dtrace command invocation:

command.arg("-x");
command.arg("encoding=utf8");

But I ran into the same error seemingly just as often.


This is admittedly a hack, so I understand if you don't want to merge it, but it might be helpful for folks like me experiencing #32.

Anecdotally this commit seems to completely fix things for me. Without it I get the above error about 50% of the time — making it quite frustrating to use this otherwise very nice tool. 🙂

The caveat is that presumably the invalid symbol names will not be correctly labeled/classified, but in practice this hasn't bitten me yet, since it seems to be a relatively small number of affected lines.

Intermittently, invalid utf-8 is found in cargo-flamegraph.stacks, which
causes parsing to blow up with the error:

> unable to collapse generated profile data: Custom { kind: InvalidData, error: StringError("stream did not contain valid UTF-8") }

This commit doesn't fix the underlying problem, but simply works around
it by lossily re-encoding to valid utf8.

Anecdotally it seems to be macos symbol names at the end of the line that
contain the invalid utf-8 - I don't know if this is due to some error in dtrace
or if somehow the symbols actually contain non utf-8 encodings.

Note I did try explicitly specifying utf8 output, by adding to the
dtrace command invocation:

    command.arg("-x");
    command.arg("encoding=utf8");

But I ran into the same error seemingly just as often.
@spacejam
Copy link
Contributor

spacejam commented Dec 7, 2020

Thanks for the workaround! I have also been bitten by this on OSX and I think this is an acceptable workaround for the time being. I've been bitten by a large number of annoying filesystem issues on OSX over time...

I'll be cutting a new release in a few minutes that includes this change if bors is happy.

bors r+

@bors
Copy link
Contributor

bors bot commented Dec 7, 2020

@bors bors bot merged commit 0105eb1 into flamegraph-rs:master Dec 7, 2020
@spacejam
Copy link
Contributor

spacejam commented Dec 7, 2020

Version 0.4 has been released which includes these changes. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants