Skip to content

Update to CBMC 5.12 #152

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 3 commits into from
Aug 31, 2021
Merged

Conversation

FrNecas
Copy link
Contributor

@FrNecas FrNecas commented Aug 19, 2021

There have been a lot of changes in this pull request. Below is just a short overview of the most significant ones and some comments:

  • Vast abstract interpretation changes, usually required adding explicit initialization to bottom. I was also a bit struggling with constant propagator throwing failed to find state error but it turned out I had to call it a bit differently to make it initialize states.
  • Function identifier was removed from goto instruction ( remove goto_programt::instructiont::function member [blocks: #3113] cbmc#3126 ) which caused some problems. I usually ended up using the indentifier stored in SSA and passing it around. One case where it behaves slightly differently is inlining (previously the original function was kept even during inlining). This caused issue in trying to ignore __CPROVER_initialize function (mainly the variables assigned in it), we ended up checking for the CPROVER prefix in the variables rather than looking at the functions.
  • Removed property checker (5b05f18) required a lot of changes. We also noticed that new assertion status was added (previously it was unknown - ok - fail, now there is also not checked). We ended up sticking with UNKNOWN for now (for compatibility) but this may be a place for potential refactoring (differentiating between not having checked the property and having checked it but not knowing its correctness).
  • Significant solver changes - we ended up using the contexts provided by CBMC rather than the previous implementation. This seems to have also sped up the calculations which is great!
  • And a lot of other small API and call changes, too many to list them all
  • We agreed with @viktormalik to temporarily disable one test ( 80deaff). I've been trying to find the issue in it for hours, however no luck yet and I'd rather get this going again and fix this one small issue (along with true memsafety tests that we disabled some time ago) once it's all done. The formulae pushed to the solver seem to be the same but in the new version it throws UNSAT, whereas in the old it resulted in SAT. Such issues are almost impossible to debug since the solver is basically a black box.

Looking at the CI failures, I will push one more commit with code style fixes (will squash it at the end). I don't really know why compilation with clang++3.7 is failing but it seems to come from CBMC so probably not much I can do about that...

Related: peterschrammel/cbmc#25

Copy link
Collaborator

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

Just some nits, LGTM overall.

@FrNecas
Copy link
Contributor Author

FrNecas commented Aug 20, 2021

Thanks for the review, addressed your comments in a separate commit (since it won't be visible in the final commit after squashing anyway)

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Thanks for this well-structured and easy-to-review PR.
I'd prefer putting CI back in place before merging this.
E.g. I cannot compile locally atm under GCC 9.3.0 (Ubuntu 20) without turning off warning-is-error.

result=typecast_exprt(sum, address.type());

return result;
}
Copy link
Member

Choose a reason for hiding this comment

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

What does this branch return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can understand, it converts an expression where a member is accessed to an expression where offset is used instead of the member.

@@ -112,13 +115,22 @@ bool twols_parse_optionst::unwind_goto_into_loop(
loopst loops;
Forall_goto_program_instructions(i_it, body)
{
if(i_it->is_backwards_goto())
Copy link
Member

Choose a reason for hiding this comment

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

(independent of this PR) If you think that this is a bug in goto program it may be worth creating a unit test for goto program that reproduces the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it may be a bug, though I am not completely sure. In one of our regression tests (termination/ite4), this call resulted in a segfault. We tried to investigate it but it was very weird - we successfully entered the method (hence i_it is fine) but the number of targets of the goto was huge so I'd guess that's where the bug came from (iterating over the targets and accessing a weird memory location).

It may have already been fixed in a later version of CBMC. We could try to revert this commit once we are close to CBMC:develop and if it still fails, we can try to find the root cause + add a unit test. Or maybe could you try it if you have latest CBMC setup? The reproducer is very simple:


int foo(int x)
{
  int res;
  if(x) return 0;
  else return 1;
}

int bar(int x)
{
  int res;
  if(x) res = 0;
  else res = 1;
  return res;
}

void main()
{
  int x;
  int y = foo(x);
  assert(0<=y && y<=1);
  y = bar(x);
  assert(0<=y && y<=1);
}

If I remember correctly, the segfault happened right in the first function at if.

@FrNecas
Copy link
Contributor Author

FrNecas commented Aug 22, 2021

Thanks for the review, I will address your comments tomorrow. I'd also like to merge the CI PR first. As for the -Werror, I don't think 2LS was ever compilable with it. I remember that every time I wanted to debug (by removing the comment in src/config.inc) I would also have to remove -Werror to compile because there were some warnings coming from CBMC and some others from 2LS. Looking at CBMC compilation now, it looks very clean, no warnings as far as I can tell. My plan is to go through the warnings in 2LS once we finish the rebase and fix them, most of them should be fairly simple (missing cases, etc)

@peterschrammel
Copy link
Member

My plan is to go through the warnings in 2LS once we finish the rebase and fix them

Makes sense.

@peterschrammel
Copy link
Member

Please rebase on the submodule

Fix decision_procedure include
Update satcheckt solver creation
Update initialize method arguments
Workaround missing function id in goto instruction
Workaround changes to symbol_exprt constructor
Convert to_integer argument to const expression
Fix obtaining of entry state
Get rid of deprecated nil_typet
Fix index_exprt initialization
Replace deprecated symbol_typet
Replace get_unsigned_int with get_size_t
Replace deprecated is_procedure_local
Fix construction of byte_extract_exprt
Replace deprecated integer2ulong
Replace deprecated make_typecast
Replace deprecated find_symbols call
Fix langapi include
Fix xml_expr include
Remove unused replace method
Add constructor without arguments to row_valuet
Do not try to create symbol_exprt with 0 arguments
Refactor find_corresponding_symbol to return optionalt to achieve this
Workaround missing default constructor for symbol_exprt
Workaround missing default constant_exprt constructor in preadbs_domain
Correctly include integer_typet
Replace deprecated integer2unsigned
Fix get_loophead_selects prototype
Workaround removed property_checkert
Fix show_goto_functions call
Fix show_properties call
Fix show_defs ssa_analysis output
Fix side_effect_expr_nondett construction
Fix goto unwinding
Link with goto-checker
Initialize values to bottom
Pass message_handler to incremental_solver
Initialize states of analyses to bottom
Use NOT_CHECKED when checking status
Simplify incremental solver using CBMC's push and pop
Make solvers less verbose unless debugging
Do not add __CPROVER variables to counterexample
Avoid the use of is_backwards_goto while unwinding
 -  The method may in some cases (e.g. ite4 termination regression test)
    cause a segfault for unknown reasons. Flip the condition, check using
    incoming edges if an instruction is loop head rather than checking
    if a goto is loop exit.
Initialize properties with UNKNOWN
 -  This is better for backwards compatibility for now, since we have no way
    of checking if a property was checked or we simply could not check it.
    However this is a potential place for improvements.
Initialize constant propagator states
Update expected assert description
 -  CBMC 5.12 changed the assertion description of fields of structures to
    be more user-friendly (the field is named instead of an offset added).

Signed-off-by: František Nečas <[email protected]>
Signed-off-by: František Nečas <[email protected]>
@FrNecas FrNecas force-pushed the frnecas-cbmc-5.12 branch from a35adc7 to 8eb92b5 Compare August 30, 2021 07:54
@FrNecas
Copy link
Contributor Author

FrNecas commented Aug 30, 2021

Done, rebased and squashed

@peterschrammel peterschrammel merged commit 8e42b4f into diffblue:master Aug 31, 2021
@FrNecas
Copy link
Contributor Author

FrNecas commented Aug 31, 2021

Thanks for merging. @peterschrammel could you please create 2ls-prerequisites-cbmc-5.37.0 branch on your CBMC fork? In the meantime, I managed to get the rebase up until the latest release and I will hopefully have a PR with final changes soon (the number of changes was not huge). My intention right now is to have 2 more PRs - one with rebase to 5.37.0 and the other fixing the compilation warnings and ideally also fixing some bugs (we would like to give the new version a try on SVcomp suite).

The only problem with the release right now is a regression in heap domain (occurred first with 5.18) which we are currently trying to debug.

@peterschrammel
Copy link
Member

could you please create 2ls-prerequisites-cbmc-5.37.0 branch on your CBMC fork?

Done.

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.

3 participants