-
Notifications
You must be signed in to change notification settings - Fork 2
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
Handling of foreign functions that may execute local code #164
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.
What Changed?
Why Does It Need To?
The main use case here is if the local code calls a higher-order function, then we should ensure that we don't miss any markers as a result. Here is a simple example from out test cases.
Our analysis would miss the
attached
marker, because it doesn't know the body ofthread::spawn
(and even if it did, it wouldn't help but more on that later). But there is a more general pattern here, which is if any foreign functionfoo
is parameterized by a traitT
which we locally implement, then a method on that trait might attach markers.So step one is to reject such calls to foreign function. If we did that for all of them however that would cause a lot of false rejection. Instead we should only reject this if the trait implementation that it might target is known to attach a marker and therefore cause an unsoundness issue.
But, as mentioned before we wouldn't be able to actually analyze
thread::spawn
, even if we had access to be body. Underneath it does some low-level stuff that Paralegal can't actually handle. However semantically it's quite simple we could basically replacethread::spawn(foo)
withfoo()
(andjoin
withidentity
).So step two is to add an interface to whitelist a set of commonly used higher order function and define some simple rewrite rules, e.g.
thread::spawn(foo) => foo()
.Checklist
good record of what changed.
if necessary
.github/workflows/rust.yml
) either as compiler test or integration test.Or justification for their omission from CI has been provided in this PR
description.