Repository navigation
Support ICE reporting using json diagnostics - #2167
Conversation
This will allow us to retrieve crash information from Kani driver.
| impl Callbacks for KaniCallbacks {} | ||
| impl Callbacks for KaniCallbacks { | ||
| fn config(&mut self, config: &mut Config) { | ||
| if matches!(config.opts.error_format, ErrorOutputType::Json { .. }) { |
There was a problem hiding this comment.
Is error_format the right place to hook? I thought that was for compiler errors. Does rustc format panic like this?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
BTW, I created rust-lang/rust#107484 to see what they way about the panic message format.
| // Print stack trace. | ||
| let msg = format!( | ||
| "Kani unexpectedly panicked at {}", | ||
| info.location().map_or(String::from("Unknown Location"), |loc| loc.to_string()) |
There was a problem hiding this comment.
What does this format as? What a panic typically prints? e.g. {path}:{line}:{column} (I think?)
There was a problem hiding this comment.
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"}
There was a problem hiding this comment.
btw, I'm changing this message to print the panic info instead, which will print the message and the location.
There was a problem hiding this comment.
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"}
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
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.