-
Notifications
You must be signed in to change notification settings - Fork 76
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
Make meet in AddressDomain more precise #1468
base: master
Are you sure you want to change the base?
Conversation
@@ -110,6 +110,11 @@ struct | |||
| StrPtr _, UnknownPtr -> None | |||
| _, _ -> Some false | |||
|
|||
let amenable_to_meet x y = match x,y with | |||
| StrPtr _, StrPtr _ -> true | |||
| Addr x, Addr y when Mval.equal (Mval.top_indices x) (Mval.top_indices y) -> true |
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.
Don't the address set buckets already guarantee this to only be called in such cases because Mval.top_indices
are the representatives?
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.
Even if the buckets guarantee this already, this function can be called with two arbitrary addresses, so we can not just return true.
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.
That's true, although it could just be an implementation detail (like the buckets themselves are), which isn't exposed to the outside by the interface. Then such misuse would be impossible.
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 followed this assumption now to just assume that things placed into the same bucket are amenable to meet, which seems to be the case in our implementation and I think also makes sense semantically.
This largely simplifies the implementation and makes all sorts of extra considerations obsolete.
Sorry for being MIA, I will take this up and hopefully get it mergeable before the holidays. |
Currently, in the address domain inside the buckets, for the meets we use
ProjectiveSetPairwiseMeet
analyzer/src/domain/disjointDomain.ml
Lines 190 to 205 in bffc5e3
where
B.may_be_equal
delegates toanalyzer/src/cdomain/value/cdomains/addressDomain.ml
Line 180 in bffc5e3
Addr.semantic_equal
given byanalyzer/src/cdomain/value/cdomains/addressDomain.ml
Lines 102 to 111 in bffc5e3
which calls
SD.sematic_equal
analyzer/src/cdomain/value/cdomains/stringDomain.ml
Lines 77 to 81 in bffc5e3
this is needed to handle all sorts of different offsets that may be semantically equal, i.e., evaluate to the same physical address. In this case it keeps both elements.
After some discussion with @jerhard and @hseidl, we reached the following insights:
This behavior is overly conservative, as the mess of the address lattice contains some sub-lattices where the
meet
operation is semantically correct.This now checks via a new predicate
amenable_to_meet
whether for the two addressesa
andb
this relationship between values and the meet holds. If this is the case, a meet is performed and the element added to the resulting set only if it is distinct frombot
.Currently, we answer
amenable_to_meet
by true whenever both arguments are strings, or when the both are addresses that differ in the numeric(!) offsets only.This PR also adds two tests where this yields additional precision.
Closes #1467