Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
101: Workaround #32 - fails parsing invalid utf8 dtrace output (macos only?) r=spacejam a=michaelkirk 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. Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
- Loading branch information