Skip to content

Conversation

@tautschnig
Copy link
Collaborator

Declarations with initialisers generate a declaration and an assignment.
The side effect in the rhs of the assignment was never cleaned up,
resulting in a failing invariant during symex for the regression test
included.

The test was built by C-Reduce on a example originating from CSmith.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #5669 (e63f895) into develop (95097a8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #5669   +/-   ##
========================================
  Coverage    69.49%   69.49%           
========================================
  Files         1243     1243           
  Lines       100674   100680    +6     
========================================
+ Hits         69962    69968    +6     
  Misses       30712    30712           
Flag Coverage Δ
cproversmt2 43.11% <100.00%> (+<0.01%) ⬆️
regression 66.38% <100.00%> (+<0.01%) ⬆️
unit 32.26% <44.44%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/goto-programs/goto_convert.cpp 90.17% <100.00%> (+0.03%) ⬆️
src/goto-programs/goto_convert_side_effect.cpp 90.86% <100.00%> (+0.17%) ⬆️

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 95097a8...e63f895. Read the comment docs.

@tautschnig tautschnig marked this pull request as draft December 15, 2020 18:03
@tautschnig tautschnig self-assigned this Dec 15, 2020
@tautschnig tautschnig force-pushed the decl-side-effect branch 3 times, most recently from 8aa31e5 to ef81046 Compare December 15, 2020 22:55
@tautschnig tautschnig marked this pull request as ready for review December 15, 2020 23:27
@tautschnig tautschnig assigned kroening and unassigned tautschnig Dec 15, 2020
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.

Seems reasonable.

@tautschnig tautschnig assigned tautschnig and unassigned kroening Dec 17, 2020
@tautschnig tautschnig marked this pull request as draft December 17, 2020 00:11
@tautschnig tautschnig marked this pull request as ready for review December 17, 2020 01:02
@tautschnig tautschnig assigned kroening and unassigned tautschnig Dec 17, 2020
// make sure the resulting expression has the same type as before.
exprt lhs = typecast_exprt::conditional_cast(
skip_typecast(to_binary_expr(expr).op0()), expr.type());
expr.swap(lhs);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a bit worried about the skip_typecast, since that may remove any number of casts.

Say think of (int)(char)i, where i is an integer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for calling this out! I have now added sanity checks and refrained from using skip_typecast.


// we previously weren't able to handle the below
short a = (a ^= 0) || __assert_fail("", 2, __PRETTY_FUNCTION__);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would replace the architecture-specific __assert_fail by some other side effect, say x++ or the like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done (I've added a call to a newly added function, which in turn calls __CPROVER_assert).

{
// Skip over those type casts, but also
// make sure the resulting expression has the same type as before.
PRECONDITION(to_typecast_expr(lhs).op().type() == expr.type());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add a DATA_INVARIANT here to check that the typecast is there, and turn that PRECONDITION into a DATA_INVARIANT.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Declarations with initialisers generate a declaration and an assignment.
The side effect in the rhs of the assignment was never cleaned up,
resulting in a failing invariant during symex for the regression test
included.

The test was built by C-Reduce on a example originating from CSmith.
@kroening kroening merged commit bcb25ed into diffblue:develop Dec 23, 2020
@tautschnig tautschnig deleted the decl-side-effect branch December 23, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants