Skip to content

Fix a crash during SMT translation of structs #5904

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

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

SaswatPadhi
Copy link
Contributor

@SaswatPadhi SaswatPadhi commented Mar 9, 2021

This PR fixes a bug with SMT translation of structs using data types (not bit vectors). CBMC --smt2 --z3 was crashing on the attached regression test with a key not found exception from a map::at call.

  • Each commit message has a non-empty body, explaining why the change was made.
  • NA Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • NA The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • NA My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@feliperodri feliperodri added the aws Bugs or features of importance to AWS CBMC users label Mar 9, 2021
@codecov
Copy link

codecov bot commented Mar 9, 2021

Codecov Report

Merging #5904 (c2ec649) into develop (e76d811) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5904      +/-   ##
===========================================
+ Coverage    75.12%   75.14%   +0.02%     
===========================================
  Files         1435     1435              
  Lines       156301   156303       +2     
===========================================
+ Hits        117416   117455      +39     
+ Misses       38885    38848      -37     
Impacted Files Coverage Δ
src/solvers/smt2/smt2_conv.h 100.00% <ø> (ø)
src/solvers/smt2/smt2_conv.cpp 60.86% <100.00%> (+1.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f7dcb5...c2ec649. Read the comment docs.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Please can you reformat this a little to fix with current conventions.

@kroening
Copy link
Member

Should there be a similar change for union_tags?

@SaswatPadhi
Copy link
Contributor Author

Should there be a similar change for union_tags?

Unions are currently not encoded using data types in SMT, so this particular issue doesn't appear with unions.

But I haven't checked if we would have a similar issue with non-DT encoding of unions and structs. We do something similar for bit vector encodings -- instead of looking up the datatype_map, we look up boolbv_width of the type. I will check this and create a separate PR to fix the BV encoding, if needed.

@SaswatPadhi SaswatPadhi force-pushed the smt_struct_fix branch 3 times, most recently from 7442aa6 to 5c0a2ca Compare March 10, 2021 17:00
@SaswatPadhi
Copy link
Contributor Author

SaswatPadhi commented Mar 10, 2021

I think the test is failing in CI because it cannot find z3.

Is there a way we can just test the SMT constraint generation with data types enabled, without actually solving them using z3? Alternatively, we can install z3 on our CI :)

@thomasspriggs
Copy link
Contributor

I think the test is failing in CI because it cannot find z3.

Is there a way we can just test the SMT constraint generation with data types enabled, without actually solving them using z3? Alternatively, we can install z3 on our CI :)

It seems reasonable to install an SMT solver in CI in order to test the SMT output properly. Just so long as we don't end up giving it anything to solve which inflates the overall run time too much. @diffblue/diffblue-opensource What do the rest of you think?

Please note that I haven't reviewed the rest of this PR, I am just trying to help with this particular issue.

@SaswatPadhi
Copy link
Contributor Author

Thanks @thomasspriggs.

@martin-cs I think I have addressed your comment regarding conventions. There is one remaining issue with smt-backend tag which I have described above. Could you please take another look?

Copy link
Contributor

@thomasspriggs thomasspriggs left a comment

Choose a reason for hiding this comment

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

The fix appears reasonable to me. But we need get the test to run and pass in CI, before I will be happy to approve. This so that the additional CI related changes can be reviewed and approved before merging.

@SaswatPadhi SaswatPadhi force-pushed the smt_struct_fix branch 2 times, most recently from f6001d7 to dec30a2 Compare March 17, 2021 20:08
@SaswatPadhi SaswatPadhi changed the title Fixes a crash in SMT translation of structs Fix a crash in SMT translation of structs Mar 18, 2021
@SaswatPadhi
Copy link
Contributor Author

Blocked on #5949.

@thomasspriggs
Copy link
Contributor

Blocked on #5949.

I only raised that PR to run CI, it is in Draft status and the work in known to be incomplete. We are currently giving higher priority to other pieces of work. It could be a week or so, before we come back to those CI changes. Is that going to be a problem for you?

@SaswatPadhi
Copy link
Contributor Author

Hi @thomasspriggs,

No problem. I was going through all of my PRs and rebased some of them with develop. This is just a note to myself. I have things running locally for demos etc. so this is not a high priority for now.

Thanks.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Looks good; thanks.

This commit fixes a `key not found` exception in `convert_type` during SMT2 encoding of structs using data types. Although structs were being mapped to SMT2 datatypes (in `datatype_map`) struct_tags were not.
@SaswatPadhi SaswatPadhi changed the title Fix a crash in SMT translation of structs Fix a crash during SMT translation of structs Mar 31, 2021
@SaswatPadhi SaswatPadhi merged commit e42cc6c into diffblue:develop Mar 31, 2021
@SaswatPadhi SaswatPadhi deleted the smt_struct_fix branch March 31, 2021 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users bugfix SMT Backend Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants