Skip to content
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

Vscode Extension Timeout Handling #60

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

umutdural
Copy link
Collaborator

This PR adds the following features:

  • LSP server also uses hard fallback timeouts.
  • Better diagnostic text to unknown results returned from the SMT solver.
  • When a timeout occurs, unknown result is returned for the rest of the procedures which are not yet checked.

Copy link
Collaborator

@Philipp15b Philipp15b left a comment

Choose a reason for hiding this comment

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

Thanks! I left some minor comments.

src/main.rs Outdated
@@ -595,105 +601,137 @@ fn verify_files_main(

let mut num_proven: usize = 0;
let mut num_failures: usize = 0;
let mut wrapping_up: bool = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a comment here saying that this is set to true if we had a timeout and just need to mark all remaining procs as unknown.

src/main.rs Show resolved Hide resolved
src/servers/lsp.rs Show resolved Hide resolved
@@ -72,6 +73,9 @@ pub trait Server: Send {
result: &mut SmtVcCheckResult<'ctx>,
translate: &mut TranslateExprs<'smt, 'ctx>,
) -> Result<(), ServerError>;

// Sends an unknown verification result for the not checked proc with the given span.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be a rustdoc comment with ///?

Copy link
Collaborator

@Philipp15b Philipp15b left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Just a couple of minor comments and one (optional) idea.

@@ -720,7 +742,7 @@ fn verify_files_main(
match res {
Ok(_) => Ok(()),
Err(VerifyError::LimitError(_)) | Err(VerifyError::Interrupted) => {
wrapping_up = true;
limit_interrupt_error = Some(res.unwrap_err());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not bind the err in the pattern matching and use that instead of doing res.unwrap_err()?

Vcgen { tcx, explanation }
pub fn new(
tcx: &'tcx TyCtx,
explanation: Option<VcExplanation>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: use order tcx, thenlimits_ref, then the optional explanation

@@ -504,6 +504,10 @@ fn verify_files_main(
server: &mut dyn Server,
user_files: &[FileId],
) -> Result<bool, VerifyError> {
// Limit errors or interrupts are saved here. Then rest of the procs are marked as unknown.
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this seems to work, I find this somewhat error-prone and ugly. What do you think of this idea: We first register all source units in the server and mark them as unprocessed/unfinished/WIP. Then, when one proc results in a timeout, it is a) easy to mark all others as unknown in the UI, b) easy to identify the culprit (by distinguishing timeout vs unfinished), c) impossible to forget handling the LimitErrors/Interrupted in each loop.

Hopefully that idea can avoid all of those extra match statements that were necessary to introduce in this patch.

@@ -65,7 +71,12 @@ pub fn pretty_vc_value<'smt, 'ctx>(
|_ident| expr_true.clone(),
);
let mut res = subst_expr;
apply_subst(translate.ctx.tcx(), &mut res);
let deadline = Instant::now() + Duration::from_millis(1);
let _ = apply_subst(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you discard the result here? Please add a comment

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