Skip to content

Support ICE reporting using json diagnostics - #2167

Merged
celinval merged 2 commits into
model-checking:mainfrom
celinval:issue-2165-ice
Jan 30, 2023
Merged

celinval merged 2 commits into
model-checking:mainfrom
celinval:issue-2165-ice

Conversation

@celinval

Copy link
Copy Markdown
Contributor

Description of changes:

This will allow us to retrieve crash information from Kani driver once we merge #2166.

Resolved issues:

Part of #2166

Related RFC:

Call-outs:

For now, I'm only added the line where the crashed occurred. I think it's probably our best mechanism today to categorize crashes. Does anyone have another suggestion?

Unfortunately this doesn't cover issues that happen before callback configuration, which is mostly argument parsing.

Testing:

  • How is this change tested? I manually tested this one by injecting a failure in the compiler.

  • Is this a refactor change? No

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

This will allow us to retrieve crash information from Kani driver.
@celinval
celinval requested a review from a team as a code owner January 28, 2023 01:36
Comment thread kani-compiler/src/main.rs
impl Callbacks for KaniCallbacks {}
impl Callbacks for KaniCallbacks {
fn config(&mut self, config: &mut Config) {
if matches!(config.opts.error_format, ErrorOutputType::Json { .. }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is error_format the right place to hook? I thought that was for compiler errors. Does rustc format panic like this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, to the best of my knowledge, that is the best place that works today. That is the option that rustc exposes to generate messages in json format: https://doc.rust-lang.org/rustc/command-line-arguments.html#--error-format-control-how-errors-are-produced. Which is used by cargo when you select json message format: https://doc.rust-lang.org/cargo/commands/cargo-build.html#display-options.

I initially tried to invoke report_ice API from rustc, but that actually did not produce a json message while reporting the ICE. I actually think that is a rustc issue. When rustc crashes, it is not emitting the panic message in json format. This is probably because the panic hook is initialized before parsing the arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW, I created rust-lang/rust#107484 to see what they way about the panic message format.

Comment thread kani-compiler/src/session.rs Outdated
// Print stack trace.
let msg = format!(
"Kani unexpectedly panicked at {}",
info.location().map_or(String::from("Unknown Location"), |loc| loc.to_string())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this format as? What a panic typically prints? e.g. {path}:{line}:{column} (I think?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an example:

{"message":"Kani unexpectedly panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:2196:9","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: Kani unexpectedly panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:2196:9\n\n"}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

btw, I'm changing this message to print the panic info instead, which will print the message and the location.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So now it will be:

{"message":"Kani unexpectedly panicked at panicked at 'no entry found for key', compiler/rustc_borrowck/src/region_infer/mod.rs:2196:9.","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: Kani unexpectedly panicked at panicked at 'no entry found for key', compiler/rustc_borrowck/src/region_infer/mod.rs:2196:9.\n\n"}

@celinval
celinval merged commit 79f86f9 into model-checking:main Jan 30, 2023
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