Skip to content

Handle measureme panics, and don't crash the collector on self-profile data errors #2016

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

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

lqd
Copy link
Member

@lqd lqd commented Nov 28, 2024

Situation: rustc creates invalid -Zself-profile data, the collector tries to read it and measureme crashes or returns an error => the collector panics (likely after 5 tries). On panics, the perf run is incomplete and the collector will try to complete it, which will still crash. This happened today in this run.

This PR:

  • wraps measureme's panics (until I fix it there to remove the unwraps/expects) so that the collector in turn doesn't crash on randomly invalid self-profile data, and returns an error
  • if any errors happen with the self-profile data, instead of the collector panicking here, we consider this case as self-profile data missing. This is already handled by the self-profile page as far as I can tell so it should not be catastrophic (compared to infinite looping on a benchmark crash).

In the future we'll need to do another pass at error-handling and tightening up these cases. We'd ideally record any such issue as a benchmark failure, and move on to the other benchmarks.

This should do until then, I think.

lqd added 2 commits November 28, 2024 16:44
this avoids crashing the collector and acts as if we had no data, which
is not incorrect
let res =
std::panic::catch_unwind(|| analyzeme::ProfilingData::from_paged_buffer(data, None));
let results = match res {
Ok(Ok(profiling_data)) => profiling_data.perform_analysis(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also need to be in the catch_unwind?

Copy link
Member Author

@lqd lqd Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that from the buffers being read (+ validation), then the data should be in a better shape, but I don't know for sure. I haven't checked deeply into the entire call stack there as the panics were really at the start of the entire process, but there are no obvious unwraps in this method at least.

@lqd
Copy link
Member Author

lqd commented Nov 28, 2024

And we should be able to remove the catch_unwind when rust-lang/measureme#239 is merged, a release is published and we update the collector to it.

@Mark-Simulacrum Mark-Simulacrum merged commit cdeef1f into rust-lang:master Dec 9, 2024
11 checks passed
@lqd lqd deleted the self-profile-issue branch December 9, 2024 13:33
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