-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix ast/base.py hash issues #296
Conversation
Unit Test Results 94 files + 84 94 suites +84 1h 49m 17s ⏱️ + 1h 48m 49s For more details on these errors, see this check. Results for commit 17f9151. ± Comparison against base commit adbf300. ♻️ This comment has been updated with latest results. |
else: | ||
h = Base._calc_hash(op, a_args, kwargs) if hash is None else hash | ||
@classmethod | ||
def __init_with_annotations__(cls, op, a_args, depth=None, uneliminatable_annotations=None, |
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.
__new_with_annotations__
?
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 is a better name for this function, in my opinion. If we want to change that I'll need to see where else it is used and do a synced change
Ping @ltfish Regenerate all caches please |
The reason why you couldn't regenerate caches locally: https://github.com/angr/claripy/blob/fix/hash-fail/claripy/ast/base.py#L250 Can you fix it (by removing the |
5269a85
to
58981c9
Compare
58981c9
to
88ccf08
Compare
ROP caches updated. You will want to rebase this branch on master to re-trigger the CI. |
@ltfish The same issues I was seeing before still seem to occur in the CI. |
@zwimer what issue? |
The four decompiler test cases fail because the |
You should only pay attention to the "push" tests since "PR" tests do not synchronize repos based on the same branch name. |
@ltfish The push CI is failing too: https://github.com/angr/claripy/actions/runs/3841788720/jobs/6576714321 |
That's exactly what my reply was about. |
This fixes multiple issues:
str
)._hash
values for ASTs. Notice howclaripy/claripy/ast/base.py
Line 226 in 51d1753
claripy/claripy/ast/base.py
Line 239 in 51d1753
Fundamentally, if
._hash
is never used as a hash of the AST, this isn't an issue; i.e. if onlyhash(my_ast)
is used it is ok because we do convert in that function on demand. The problem is, that._hash
is used as the hash.claripy/claripy/ast/base.py
Line 218 in 51d1753
hash(0.0) == hash(-0.0)
here:claripy/claripy/ast/base.py
Line 221 in 51d1753
not annotations
._calc_hash
to determine what key to enter into a hash cache for looking up existing ASTs; since for some cases our cache uses the tuples made via our fast-path here:claripy/claripy/ast/base.py
Line 218 in 51d1753
claripy/claripy/ast/base.py
Line 253 in 51d1753
Base.__new__
andBase.__init_with_annotations__
.Base.__init_with_annotations__
where we didn't use the leaf cache at all and instead were looking for leaves in the non-leaf cache:claripy/claripy/ast/base.py
Line 251 in 51d1753
self._hash
was not always calculated via_calc_hash
but sometimes as a tuple (see point 1).base.py
's_d
functionclaripy/claripy/ast/base.py
Line 58 in 51d1753
+0.0
vs-0.0
; thus deserialization may be incorrect._d
always takes an integer (orstr
) as a hash, deserialization will lead to ASTs with corrupt_hash
s because of point 1.Before merging:
Linked: angr/binaries#101