Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR fixes several issues (one of them found by @tochilinak) related to memory regions composition and adds tests for them.
The issue with ITEs
Suppose you have a region reading, stored in a leaf of an ite. Let's assume, that the guard on the path to the leaf discards the case when the key of the reading equals
null
. Now what if we try to compose the reading onto a model heap? Both true and false branches of the ite will be recursively composed, and one of them will be chosen accordingly to the condition in the ite. Therefore, if the key of the reading maps intomkConcreteHeapRef(0)
in the model, we will anyway read from the context heap by this key and get an RE. Example:Solution:
First, calculate a condition of an ite, then a necessary branch.
NB:
The problem still exists, if we have a guard inside a
KAndExpr
,KOrExpr
, etc. How? Suppose, the first clause verifies the key can't be equal tonull
and the second one reads by this key from a region. We can't determine which clause to compose firstly, so If a model maps the key into0x0
, we have a problem.The issue with the predicate on a default value in
splittingRead
Suppose you have an allocated array reading, so the
defaultValue
equals tonullRef
. Then in a model, we compose thedefaultValue
to the0x0
, then if the sort of the region isaddressSort
, we perform a splitting read, which has the following check:So the reading from the composed region fails.
Solution:
There are two options:
Anyway, I think, the whole splitting read mechanism should be refactored, because it takes O(n^2) time. Let's wait for containers and revision this again.
PR TODO: