Skip to content

Add zero-init, and put it behind an unsound feature flag - #1521

Merged
danielsn merged 14 commits into
model-checking:mainfrom
danielsn:zero_init_feature
Sep 3, 2022
Merged

danielsn merged 14 commits into
model-checking:mainfrom
danielsn:zero_init_feature

Conversation

@danielsn

@danielsn danielsn commented Aug 15, 2022 •

Copy link
Copy Markdown
Contributor

Description of changes:

  1. Adds support for zero initializing otherwise uninit variables during codegen. This may enable CBMC to do more constant propegation, but at a potential soundness cost.
  2. Adds a new flag for potentially unsound features. This requires users to explicitly opt-in to using potentially unsound features.
  3. Use that flag to guard the 0 init code.

Resolved issues:

Resolves #1493

Call-outs:

Using this may improve performance, at a potential soundness cost. Since the tradeoff is not clear, putting it behind a flag to allow experimentation, but keeping the current default for now.

Depends on #1520

Testing:

  • How is this change tested?

    1. Existing regression tests. Turned on the flag, all regressions still pass, except for ones testing maybe_uninit, which we would expect to fail.
    2. Existing regression tests. Flag off, all regressions still pass.
    3. New test which maybe_units a variable and checks that it is all 0.
  • Is this a refactor change? No

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.

@danielsn
danielsn marked this pull request as ready for review August 31, 2022 18:32
@danielsn
danielsn requested a review from a team as a code owner August 31, 2022 18:32

@celinval celinval left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I recall this correctly, we had agreed to put unsound stuff behind a compilation flag instead of a switch.

@celinval celinval left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have mixed feelings about this one. It might be nice to get a second opinion... (@zhassan-aws?)

Honestly, I would like us to have a better defined story for how we should handle under-approximations. For example, how can we reflect the possibly unsound results in the verification report.

I was also hoping that an experimental change would be more contained too.

What if instead of adding --enable-unsound-experiments --zero-init-vars you add something like --enable-unsound-experiments=[zero-init-vars | <other_opt>]+. This will allow a more generic parser code, and the next experimental feature would only need to add a new value instead of adding new switches everywhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: ///

Comment thread .github/workflows/kani.yml Resolved
Comment thread kani-driver/src/args.rs Resolved
@celinval

Copy link
Copy Markdown
Contributor

I forgot to mention, but it might be nice to add an expected test that ensures that this feature is not available in the release mode.

@zhassan-aws zhassan-aws left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good overall. I agree with @celinval, that the --enable-unsound-experiments option should not be needed since the whole package would have been built with this feature enabled.

I also think we should clearly indicate in the report that the results may be unsound. We don't need to go as far as changing every "SUCCESS" in the results to something else, but we should at least print at the beginning and end of the report something along the lines of:

WARNING: The specified `--zero-init-vars` option may result in false proofs.

Results:
....

VERIFICATION:- SUCCESSFUL
***Note: The results above may be unsound due to the usage of the `--zero-init-vars` option.

@celinval
celinval dismissed their stale review September 1, 2022 18:18

Unblocking the PR after the last round of changes. Thanks!

Comment thread kani-driver/src/unsound_experiments.rs Resolved
@zhassan-aws

Copy link
Copy Markdown
Contributor

The refactoring to move all unsound experimental code to a separate module made things much cleaner. Thanks!

@danielsn
danielsn merged commit ab6a5ec into model-checking:main Sep 3, 2022
@danielsn
danielsn deleted the zero_init_feature branch September 3, 2022 03:21
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.

Mechanism to safely enable unsound experimental features

3 participants