Rework how to handle sensitivity with interfaces#4
Closed
henriman wants to merge 20 commits into
Closed
Conversation
jcp19
reviewed
Apr 22, 2025
jcp19
left a comment
Collaborator
There was a problem hiding this comment.
Yes, much better! I have a few minor comments that should be addressed before merging
... in `fmt.Stringer` and `flag.Value`
Cf. Gobra issue #943
Precondition is unnecessary, the file succesfully verifies even without it.
* adapt according to PR 944 from Gobra * fix parsing issues with slayers * fix remaining parsing errors * fix missing parsing error
As `Sprintf` takes input of type `interface{}`, which may also contain
pointer types, it is not clear how to require the input to be low.
…into sif-io-spec
Owner
Author
|
I have added some improvements to this branch beyond how to handle sensitivity with interfaces. For this reason, I will close this PR (and PR #3) and open a new PR (#5) for merging |
Closed
Owner
Author
|
Note that since closing this PR, I preferred calling |
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.
Current approach
In addition to
Mem, I introduced aLowMempredicate containing the necessary sensitivity information.This approach has a few problems, the most notable here being:
LowMemneeds to repeat the access permissions inMemin order to make the sensitvity information self-framing. This leads to awkwardly splitting up the access permissions, replacingMem()byacc(Mem(), 1/2) && acc(LowMem(), 1/2)LowMemgets rather tedious and requires a lot of changes (cf. the current approach tostrings.Builder)(Note that my approach to instead use an abstract predicate together with "unfolding/folding functions" is not sound, as the underlying data may be changed without "invalidating"
LowMem.)New suggested approach
I add a new function to the interface, indicating whether the underlying data is low or not.
Due to Gobra issue 846,
IsLowcan currently not be implemented. However, in the meantime, we can introduce abstract "reveal/hide functions" to work withIsLowanyway. Consider e.g. a structSwith one fieldx int:This approach doesn't suffer from the disadvantages listed above (and is also sound; as
IsLowdepends onMem, after modifying the underlying dataIsLowdoesn't hold anymore and we need to establish it again).Furthermore, this is close to how we would prefer to specify sensitivity for interfaces; once Gobra issue 846 is resolved, we can just implement
IsLowconcretely (and either remove the reveal/hide functions, or simply introduce a body).The only drawback I have encountered up to now can be seen in
pkg/addr/isdas_spec.gobra, where bothIAand*IAimplement different interfaces specifying suchIsLowfunctions; implementingIsLowforIA(s.t.(*IA).IsLowshould resolve to this method as well) leads to strange error messages, which can't be worked around in the same way as 449. However, by giving the functions distinct names across the interfaces, this can be worked around as well.Still contains workarounds for bugs:
IAand*IAto share the sameIsLowfor their respective interfaces