-
Notifications
You must be signed in to change notification settings - Fork 77
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
Bitfield Domain #1623
Bitfield Domain #1623
Conversation
…d some revision. Possible side-effects and runtime in O(n^2) while O(n) should be possible.
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.
Semgrep OSS found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
…act bitfield by eliminating constants that would result in a shift to zero beforehand
* implemented modulo * current changes * implementation of add, sub, mul based on paper * implemented neg * bug fixes for arith operators --------- Co-authored-by: Adrian Krauß <ge96kir@tum.de>
Overflow and wrapping
More Pull request feedback
…s not assume sign bit extension with negative first param
…lyzer into pull-request-feedback
Thanks for addressing my comments! I think I'm now satisfied. There are some unresolved comments from @michael-schwarz and @jerhard among the hundreds of "hidden items" above. So before merging those should be still considered. Just nothing it here since they're hidden by default and thus easy to miss. |
The old ones were almost all addressed, I closed them. The open one is this one #1623 (comment) and the one about Great job everyone 💯 🎉 🎉 |
change refinement as requested
Overview
This pull request enhances the existing
IntDomain
by introducing a new BitfieldDomain. The fullIntDomain
now consists of(DefExc, Interval, Enums, Congruence, IntervalSet, Bitfield)
.The new Bitfield Domain is based on the Paper
Abstract Domains for Bit-Level Machine Integer and Floating-Point Operations
, and keeps track of each bit in an integer individually (conceptually, this is similar to a boolean lattice for each bit).This allows for very precise analysis of bitwise operations.
The new domain can be enabled with
--enable ana.int.bitfield
Example
For example, joining$of\_int(8) \sqcup of\_int(10) \equiv 0b1000 \sqcup 0b1010 = 0b10?0$ maintains most information about the bits; only the second bit differs in both numbers and therefore becomes unknown (unknown bits are shown using a question-mark symbol).
In this case, no over-approximation happens and the join is exact.
Bitwise operators such as
&, |, <<, >>, ~, ...
can now deal with this information very precisely.Refinements
As the existing
IntDomain
allows for mutual refinements of the subdomains, this PR also adds all newly possible refinement directions to improve precision in theIntDomain
.We did, however, have some problems with non-termination when using refinements.
Some of these issues are however also present on the master branch, and indicate a more fundamental problem with refinements (See #1671).
Note
This implementation is part of the
Automated Bug Hunting and Beyond
practical course at TUM.