-
Notifications
You must be signed in to change notification settings - Fork 274
Reachability slicer: split cfg walks into two phases #3218
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
Reachability slicer: split cfg walks into two phases #3218
Conversation
3ef6172
to
4d1cc88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 4d1cc88).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88799021
/// \param criterion the criterion we are trying to hit | ||
void reachability_slicert::fixedpoint_from_assertions( | ||
const is_threadedt &is_threaded, | ||
slicing_criteriont &criterion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the side effects on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None. Pushed an extra commit to constify these, at the risk of @tautschnig's ire re: scope creep ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There you go :-)
^SIGNAL=0$ | ||
main\(\) | ||
-- | ||
^warning: ignoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check that b
is not in the slice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is in the slice, since it calls c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, the forward walk is not used in the way I assumed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test that actually slices away something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original cbmc/reachability-slice has two tests looking for slicing. These new ones were particularly looking for over-slicing since that's the bug @polgreen / @tautschnig encountered.
The first phase walks outwards towards __CPROVER__start, visiting all callers but recording callsites seen en route, then the second phase walks into callees not seen in the first phase, restricting the search to known reachable functions. This fixes the previous algorithm, which attempted the same logic but could visit too few functions when a particular functions was encountered as a callee before later being seen as a caller -- the latter results in more code being visited because the calling context is unknown, and so must be done first.
1a7b501
to
0b64e10
Compare
This enables us to use a const-ref in the reachability and full slicers.
0b64e10
to
0d8e3c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 0d8e3c1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88837602
As a side remark before getting to the key parts: "Constify slicing_criteriont::operator()" would make for a nice separate PR - it could likely be merged more or less immediately, but also it may need to be reverted in future in case someone comes up with a criterion that evolves as you query it (maybe that's weird, but that was my thinking when I originally wrote this code and I thus left it non-const). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok, but I can hardly believe we'd be the first to solve this problem. @kroening mentioned BEBOP (I think that would be Fig. 3 of https://drona.csa.iisc.ac.in/~deepakd/tpa-2016/bebop.pdf), and there might be others. If at all possible, we should be re-using algorithms and terminology and refer to those for documentation.
I find it quite hard to parse those academic code listings with highly abbreviated and subscript-littered function and variable names, but I don't think this particularly relates to their reachability algorithm, because the algorithm described in Figure 3 starts at the head of |
I'll have a search for something comparable though, and let you know what I find. Merging these meanwhile, then will follow up with a doc PR if I find anything. |
The first phase walks outwards towards __CPROVER__start, visiting all callers but recording
callsites seen en route, then the second phase walks into callees not seen in the first phase,
restricting the search to known reachable functions. This fixes the previous algorithm, which
attempted the same logic but could visit too few functions when a particular functions was
encountered as a callee before later being seen as a caller -- the latter results in more code
being visited because the calling context is unknown, and so must be done first.
This is an alternative to #2748, see comments there for more detail.