-
Notifications
You must be signed in to change notification settings - Fork 273
consider array_set expressions in the full-slice (do not merge) #898
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
Conversation
src/goto-instrument/full_slicer.cpp
Outdated
@@ -60,6 +60,10 @@ void full_slicert::add_function_calls( | |||
queuet &queue, | |||
const goto_functionst &goto_functions) | |||
{ | |||
// do not retain calls of empty functions | |||
if(node.PC->function.empty()) |
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'm not sure whether the comment is misleading or the code might not do what you'd expect it to do? This tests whether the function name set for a particular instruction is empty, which is unrelated to the function being called not having a function body.
@@ -1727,7 +1727,7 @@ void value_set_fit::apply_code( | |||
else if(statement==ID_fence) | |||
{ | |||
} | |||
else if(statement==ID_array_copy) | |||
else if(statement==ID_array_copy || statement==ID_array_set) |
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.
This fix should be applied in value_set.cpp as well.
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.
As just discussed on Skype, this is actually already the case.
1c4561f
to
7f74d7f
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.
This PR includes a binary blob without corresponding source. This is bound to cause license trouble.
7f74d7f
to
6c3ff3c
Compare
@tautschnig: I have replaced the goto binary by a Java program in the regression suite, which exposes the error. I have proposed a temporary fix to the problem so that we can evaluate the application of the slicer to the security benchmarks. I need to talk to @peterschrammel to check about the Java library implementation. It seems that if we verify a Java program that does not contain the library implementation in CBMC, then we get nil expressions as:
Since the full slicer does implicitly assume expression well-formedness, then we get some assertion violations in the code. |
a98ed38
to
101c652
Compare
@tautschnig: I have discussed this issue with our Java team (note that we have four or five teams at DiffBlue :-). The nil expressions are produced for those functions that do not contain a body. As @mgudemann has explained, those nil expressions are kept just to reproduce the trace of the Java program. What we do now is to check for a nil expression in the add_function_calls as follows:
In some sense, it is similar to the way that add_decl_dead currently works:
Let us know your thoughts and if you have a better solution in mind. Many thanks for your support. |
@tautschnig: These are some questions that our team has about the dependence graph, which I'm unsure how to properly answer: (1) What does the dependency analysis compute if a function has no body? |
Here is a simple example of how the slicer in this PR works for functions of the Java library that are not implemented.
Since there is no implementation for Character.isDefined, then the Java front-end instruments that method with nondet return value and side effects. The slicer replaces |
Interesting. Increases the urgency of #751.
As the dependency analysis is based on def-use, a function call to a function without body may introduce uses (all arguments) and a definition (the return value).
Working with functions without body is never sound. |
101c652
to
899b56b
Compare
On Thu, 2017-05-11 at 02:43 -0700, Lucas Cordeiro wrote:
@tautschnig: These are some questions that our team has about the dependence graph, which I'm unsure how to properly answer:
(1) What does the dependency analysis compute if a function has no body?
You might want to chat with @danpoe about this as he fixed the same
issue elsewhere.
(2) Is it sound to consider functions without body?
<pedantry>
Personally I avoid using the words "sound" and "complete" as they have
been hijacked and twisted (because everyone wants a technique that is
"sound but not complete"). I'd suggest "over-approximate" or
"under-approximate". Can you correctly handle functions without a body
in over-approximate analysis -- yes but you have to assume that they
could introduce dependencies between *anything*, so your results are
likely to be ... less helpful than you wanted.
</pedantry>
|
@martin-cs and @tautschnig: many thanks for your reply. Last Friday we had a meeting at DiffBlue together with @peterschrammel. We decided that our security scanner team is going to provide a summary for all those functions that do not have a body so that we can properly use the full-slicer for the taint analysis of Java programs. Later on I'm going to update this PR to reflect the result of that meeting. |
853ce4e
to
8847542
Compare
@tautschnig: May I ask you to review this PR? Here is a summary of all changes: (1) removed checks related to the empty function body (as discussed before in this issue); |
08db915
to
3d38441
Compare
@@ -0,0 +1,6 @@ | |||
KNOWNBUG |
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.
It seems rather impossible to infer what the problem here is from the commit message. Please either make the commit message more verbose or add comments to test.desc.
src/cbmc/cbmc_parse_options.cpp
Outdated
@@ -905,6 +906,12 @@ bool cbmc_parse_optionst::process_goto_program( | |||
{ | |||
status() << "Performing a full slice" << eom; | |||
full_slicer(goto_functions, ns); | |||
|
|||
status() << "Performing a reachability slice" << eom; | |||
if(cmdline.isset("property")) |
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 should be done before doing a full slice, and possibly should always be done (irrespective of whether full-slice is used or not).
- The indent is weird.
else | ||
reachability_slicer(goto_functions); | ||
} | ||
|
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.
Why has this been moved?
@@ -399,6 +399,8 @@ void full_slicert::operator()( | |||
const exprt &s=to_code_dead(e_it->first->code).symbol(); | |||
decl_dead[to_symbol_expr(s).get_identifier()].push(e_it->second); | |||
} | |||
else if(e_it->first->is_function_call()) | |||
add_to_queue(queue, e_it->second, e_it->first); |
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.
Add a comment that this assumes that a rechability slice has been performed, for it would otherwise add way too much to the slice.
3d38441
to
ac39dfb
Compare
ac39dfb
to
4b1c20b
Compare
The original intention of this PR was to consider array_set expressions to enable the full-slice option. This has already been merged into CBMC (https://github.com/diffblue/cbmc/blob/master/src/pointer-analysis/value_set_fi.cpp#L1507). We have now to investigate the combination of the reachability and full slicer, which I'll try to handle in a different PR. |
handle array_set expressions during the function call
in the full-slicert class. Added one test case into
goto-instrument regression for checking array_set expressions
using the full-slice option.