-
Notifications
You must be signed in to change notification settings - Fork 97
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
Join and format warnings about concurrent constructs #2135
Join and format warnings about concurrent constructs #2135
Conversation
We were emitting warnings using the `warn` macro at every occurrence of a concurrent constructs, which wasn't very user friendly. Instead, we now aggregate them and only print one warning at the end, similar to how we handle unsupported constructs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A couple of minor comments.
Also, we're currently storing the location of each occurrence, but not using it. Would it make sense to include all the locations in the warning under some flag (e.g. --verbose
) in case the user wants to find out where they're used?
Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
I thought about expanding the location with That said, I rather not do this as part of this change. I understand that the new format loses that information, so let me know if you think it is a blocker. I could also skip saving the location for now (and even drop the counter in the message). I do like the suggestion to print more information when requested (especially for unsupported constructs), which I think is even more important since it can result on a harness failure. |
Should I lower it to an info instead of warning?? @zhassan-aws |
Are you asking because we would already emit a warning if the program had other concurrency constructs (e.g. threads)? If so, I still suggest we keep it a warning to make it a bit more obvious to the user how Kani is handling them. |
No, it's fine to do this in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @celinval for doing this!
I'm in favor of merging it as is, just have a couple of comments to keep in mind.
/// Kani does not currently support concurrency and the compiler assumes that when generating | ||
/// code for some specialized concurrent constructs that this is the case. We store all types of | ||
/// operations that had this special handling and print a warning at the end of the compilation. | ||
pub fn store_concurrent_construct(&mut self, operation_name: &str, loc: Location) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, printing the location isn't useful at the moment. A better thing to do would be storing locations from function calls up to here, then print whichever is closest to the user's code. But we don't have anything like that at the moment, right?
|
||
if !ctx.concurrent_constructs.is_empty() { | ||
let mut msg = String::from( | ||
"Kani currently does not support concurrency. The following constructs will be treated \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This messaging could also be improved. In particular, I think we should avoid using "Kani" in our messages, and say something like "Concurrency is not supported at the moment". But I'm afraid this will break some stuff, so let's not do it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid using "Kani" in our messages
Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're running Kani, so it's odd printing messages that mention Kani in any way when you're already in that context. If I'm not mistaken, the Rust compiler won't use its own name in messages unless it's talking about specific editions (e.g., "this construct isn't supported in Rust 2018"). Otherwise, I feel like it becomes repetitive for users to see messages like "Kani does this" or "Kani does that" (there may be exceptions, of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, though my thoughts are:
- CBMC supports concurrency... For some of these I wonder how hard it's really be to make (at least some of) them work as intended. We could reduce the warning count to the ones we really don't handle right.
- It actually still looks like a lot of operations. Wonder if we should bother with any further condensation (e.g. "atomic load/store" as one?) But... this isn't important. Big enough improvement for one PR.
Description of changes:
We were emitting warnings using the
warn
macro at every occurrence of a concurrent constructs, which wasn't very user friendly. Instead, we now aggregate them and only print one warning at the end, similar to how we handle unsupported constructs.Resolved issues:
Resolves #1460 ??
Related RFC:
N/A
Call-outs:
With this PR, I propose that we close #1460 in favor of reducing the verbosity of those messages by aggregating them as we did for unsupported constructs. @fzaiser @adpaco-aws, would that be OK?
The output now looks like this for the test
kani/Intrinsics/Atomic/Stable/Store/main.rs
:Testing:
How is this change tested?
Is this a refactor change?
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.