Skip to content

Conversation

@celinval
Copy link
Contributor

Description of changes:

When an error that was properly handled ocurrs in kani-driver we now gracefully exit and return ExitStatus::FAILURE.

We still print all error context to keep a similar experiece to what it was before. However, this will no longer include the backtrace if users set RUST_BACKTRACE=1.

The backtrace will still be included if you enable the debug logs and also enable the backtrace. I.e.:

export RUST_BACKTRACE=1
export KANI_LOG=kani_driver=debug
cargo kani

Resolved issues:

Resolves #2064

Related RFC:

Optional #ISSUE-NUMBER.

Call-outs:

Testing:

  • How is this change tested?

  • Is this a refactor change?

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.

@celinval celinval requested a review from a team as a code owner January 28, 2023 02:14
@tedinski
Copy link
Contributor

This is at least not the fix I'd do for #2064. I think we should detect when RUST_BACKTRACE is set but RUST_LIB_BACKTRACE is not, and then default it the other way.

You can see documentation on this environment variable in: https://docs.rs/anyhow/latest/anyhow/

@celinval
Copy link
Contributor Author

It makes sense. What you are suggesting is already the current behavior though. The standard library checks those variables before generating the backtrace.

That said, it doesn't fix the problem at hand. So I think the question here is whether #2064 should be fixed in the first place. @zhassan-aws ?

@tedinski
Copy link
Contributor

I think we should fix it. The behavior I was suggesting is this:

If you want only panics to have backtraces, set RUST_BACKTRACE=1 and RUST_LIB_BACKTRACE=0.

So to fix this in kani-driver, if the former is set, and the latter is not, then we explicitly set the latter to 0.

@celinval
Copy link
Contributor Author

Ah, I see what you are saying, you think we should change the behavior only when RUST_BACKTRACE=1 and RUST_LIB_BACKTRACE isn't set, right? Why is that? Do you think people just aren't used to the second variable?

This PR mimics cargo and rustc behavior, which I think makes more sense. No matter the value of RUST_BACKTRACE and RUST_LIB_BACKTRACE, these two tools won't print the stack trace of an error that is due to a user error (like compilation error). Note that today passing the wrong argument will not print the error stack, no matter the values of these two variables.

No matter which approach we take, we should consider improving the driver error handling to make a distinction between internal tool error and user error, so this can be handled in a better way.

@zhassan-aws
Copy link
Contributor

So I think the question here is whether #2064 should be fixed in the first place. @zhassan-aws ?

I think it should be fixed, because a backtrace gives an impression that something is broken in the tool.

Copy link
Contributor

@zhassan-aws zhassan-aws left a comment

Choose a reason for hiding this comment

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

A few minor comments. Otherwise, looks good (if @tedinski is OK with the changes).

Copy link
Contributor

Choose a reason for hiding this comment

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

"consider create" -> "create" or "consider creating"

@tedinski
Copy link
Contributor

Do you think people just aren't used to the second variable?

Pretty much.

Also, just want to make it clear: I don't object to this change.

@celinval
Copy link
Contributor Author

Do you think people just aren't used to the second variable?

Yeah, tbh, I am not a big fan of the design they came up with these two variables. It's not very intuitive.

Pretty much.

Also, just want to make it clear: I don't object to this change.

Sounds good. Thanks!

When an error that was properly handled ocurrs in `kani-driver` we now
gracefully exit and return ExitStatus::FAILURE.

We still print all error context to keep a similar experiece to what it
was before. However, this will no longer include the backtrace if users
set RUST_BACKTRACE=1.

The backtrace will still be included if you enable the debug logs and
also enable the backtrace. I.e.:

```
RUST_BACKTRACE=1 KANI_LOG=kani_driver=debug cargo kani
```
@celinval celinval force-pushed the issue-2064-driver-error branch from c868ac2 to 42ff192 Compare January 31, 2023 21:01
@celinval celinval merged commit 9cb5005 into model-checking:main Jan 31, 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.

Compilation errors produce stacktraces

3 participants