UnionDomain.meet: Throw Uncomparable exception for abstract unions with different active fields#1109
Merged
UnionDomain.meet: Throw Uncomparable exception for abstract unions with different active fields#1109
UnionDomain.meet: Throw Uncomparable exception for abstract unions with different active fields#1109Conversation
…ncompatibleIKinds-exception.
…t active fields, use it in BaseInvariant. The refinement by BaseInvariant to handle branching used VD.meet, which caused issue #1105, due to the behavior of UnionDomain.meet: The meet of unions with different active fields can result in a bottom value. This led to e.g. spuriously dead code. This commit adds a function try_meet to the valueDomain, the union domain, and those domains that may contain a union domain element: structs, arrays, blobs. The function try_meet in the union domain throws an exception in the case the fields of the unions for which a meet was tried did not coincide. In case this exception occurs, the BaseInvariant does not perform refinement.
Member
Author
|
The exact behavior on analyzer/tests/regression/27-inv_invariants/19-union-char-int.c Lines 3 to 18 in 14929ca Whether this actually holds may e.g. depend on the endianness of the machine. But this is a separate issue. |
sim642
reviewed
Jul 11, 2023
…different active fields," This reverts commit 6f12ce2.
…not match. Raise an Lattice.Uncomparable exception when the active fields of the unions that the meet is applied to, do not match. Catch Uncomparable exception in BaseInvarian, and do not do refinement in case the exception is thrown during the VD.meet.
VD.try_meet function and use it instead of VD.meet in BaseInvariantUnionDomain.meet: Throw Uncomparable exception for abstract unions with different active fields
sim642
reviewed
Jul 14, 2023
The definition of the meet via Lattice.Prod (Field) (Values) is equivalent and thus does not need to be overwritten.
sim642
approved these changes
Jul 20, 2023
Member
Author
|
I had to readd the explicit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Edit: This PR changes the
meetof theUnionDomainsuch that it throws aUncomparableexception, as suggested below: #1109 (comment). TheBaseInvariantthat uses theVD.meetcatches theUncomparableexception and does not do a refinement in case it is thrown.On test case
27/18both branches of anifcomparing two unions are no longer considered dead, and test27/19does no longer crashes with theIncompatbileIkindException.Fixes #1105.
Previous Approach
This adds a functionValueDomain.try_meet, a version of themeetthat may fail for unions with different active fields and use it in BaseInvariant. @michael-schwarz and I discussed this today.The refinement by BaseInvariant to handle branching used VD.meet, which caused issue #1105, due to the behavior of UnionDomain.meet: The meet of unions with different active fields can result in a bottom value.This led to e.g. spuriously dead code.
This adds a functiontry_meetto theVvalueDomain, the union domain, and those domains that may contain a union domain element: structs, arrays, blobs. The functiontry_meetin the union domain throws an exception if the fields of the unions for which a meet was tried do not coincide.