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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,22 @@ mod arch {
temporary file",
);

buf
// Workaround #32 - fails parsing invalid utf8 dtrace output
//
// 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") }
//
// So here we just lossily re-encode to hopefully work around the underlying problem
let string = String::from_utf8_lossy(&buf);
let reencoded_buf = string.as_bytes().to_owned();

if reencoded_buf != buf {
println!("Lossily converted invalid utf-8 found in cargo-flamegraph.stacks");
}

reencoded_buf
}
}

Expand Down