-
Notifications
You must be signed in to change notification settings - Fork 6
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
Properly scope dynamic loop permissions #66
Merged
Merged
Conversation
This file contains 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.
TLDR: This is a major change, involving a refactoring/rewriting of much of the Weaver (the part that inserts the runtime checks) and the baseline checker.
This PR is ostensibly to implement proper scoping of permissions around/in
while
loops at runtime (many other changes got wrapped in, see list at end). Previously, the same set of permissions was used throughout the entire method, regardless of permission boundaries introduced by equirecursively-precise loop invariants.For example, if we have a method
and we use it in a loop like
after executing the
while
loop, we should only have gained the permissions specified by the loop invariant. That is, we would only have access to thevalue
andnext
fields of the head element, and we would not have access to any of the following fields.So, if we have
calling
print_list(list)
after thewhile
loop above should result in an error, since it does not have access to theNode
s that are referenced from the rootlist
.Prior to this change, the same set of permissions was used throughout, so the set of permissions included the permissions gained from every
prepend
call, and thus it would have access to all the nodes.This change aligns the static reasoning with the dynamic checks, and makes it possible to catch errors that stem from insufficient (precise) loop invariants earlier.
Some other changes implemented along the way:
#use
-imported methods) that analyzes which methods actually check the set of dynamic permissions, and which modify the permission set.We now track permissions only when there is a runtime check that may use those permissions, in contrast to the previous behavior where it tracked permissions anywhere that was imprecise.
Methods that only modify (but do not assert) permissions can be passed a
NULL
set of permissions, in which case they skip tracking of permissions.a. Factored out
SeparationChecks
(adds the checks necessary to ensure heap locations referenced in a single formula do not overlap)b. Factored out
InstanceCounter
(inserts the necessary code for tracking_id
of objects, now separated entirely from runtime/OwnedFields
code, reused entirely between weaver and baseline)c. Factored out
EquirecursivePrecision
(calculates equirecursive precision of specs, used in weaver and baseline)d. Added
CheckScopes
to calculate proper scoping of permissions/checkse. Added
Dependencies
for analysis of which methods require/modify permissions (see item 1)BaselineChecker
entirely. It can now omit both/either of framing and spec checks (for example, allowing only the permission passing to be done, without any assertions)runtime_*
. [Hopefully] more performant by allowing reuse ofFieldArray
instances and removing unused entries only when more space is needed.verifier
andquant-study
examples using the baseline checker.for
loop.