-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add live streaming JSON output from CBMC to prevent Kani output hang #1278
Conversation
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 should be able to define expected
tests for this, no?
scripts/cbmc_json_parser.py
Outdated
usage_error(f"Unable to complete parsing CBMC Output\n") | ||
else: | ||
usage_error(f"CBMC Output not piped to post-processing\n") | ||
return_code = 0 |
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 would use an error code 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've added a custom exit string and an error code of 1 with -
print(f"Unable to complete parsing CBMC Output\n")
sys.exit(1)
Would this work?
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.
Sorry, my comment here was not very clear.
If I'm not mistaken, this will print all lines from CBMC's output and return 0. If we change this to 1, do the regression tests still pass?
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 should have expanded more in the comments. The return code is 1 if the stream of output is interrupted , either by a broken line or broken pipe or user interrupt (Ex - keyboard interrupt). If it completes printing all the lines from CBMC, then it returns 0. I shall add this clarification to the comments on the code.
I hope this is an acceptable usage of the error code?
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.
A return code with value 0 basically means that verification is always successful.
…to Add-Piped-Output
…to Add-Piped-Output
I was able to add in a few tests and refactored the code as suggested. Let me know if they're as expected! |
@@ -42,18 +42,30 @@ impl KaniSession { | |||
cmd.arg("--json-ui"); | |||
|
|||
let now = Instant::now(); | |||
let _cbmc_result = self.run_redirect(cmd, &output_filename)?; | |||
let elapsed = now.elapsed().as_secs_f32(); |
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 call is right after the call to Instant::now()
, so it's not measuring verification time anymore.
scripts/cbmc_json_parser.py
Outdated
usage_error(f"Unable to complete parsing CBMC Output\n") | ||
else: | ||
usage_error(f"CBMC Output not piped to post-processing\n") | ||
return_code = 0 |
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.
A return code with value 0 basically means that verification is always successful.
Closed in favor of #1433 |
Description of changes:
CBMC currently reads the input from CBMC , waits for termination and writes the output to a file which goes to the parsing script. This runs into an issue when CBMC does not seemingly terminate, which makes Kani appear to be hung.
This PR changes that to show the JSON output live from CBMC which will later be consumed by the parsing to show the post processed Kani output.
For example, for the rust file -
Before -
After -
As we can , there is a long unwinding loop that's not being displayed to the user which can cause some confusion.
With this change, the user can be informed about the status of the verification live.
Resolved issues:
Related #493
Call-outs:
--use-piped-output
for now.Testing:
How is this change tested?
Hidden behind a flag to be as non-invasive as possible.
Is this a refactor change?
Yes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.