Skip to content
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

dataflow: avoid propagating offset permissions upward from field access #1031

Merged
merged 5 commits into from
Oct 15, 2023

Conversation

aneksteind
Copy link
Contributor

@aneksteind aneksteind commented Oct 4, 2023

Pointers to structs with array fields being iterated over via offset were erroneously being given OFFSET permissions. Those permissions should be limited to the fields themselves. This PR introduces a new dataflow constraint that will propagate permissions except for a specified set. When a field projection is detected, offset permissions are no longer propagated to the base pointer.

Comment on lines 948 to 949
/// Returns the [`LTy`] of an [`Rvalue`] and a boolean indicating whether or
/// not the `Rvalue` contains a field projection.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify the precise meaning of "the Rvalue contains a field projection"? Which of these count as containing a field projection?

let r1 = x.field;
let r2 = &x.field;
let r3 = &(*p).field;
let r4 = x.field + y;
// ^ Rvalue::Add(Operand::Copy(x.field), ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added clarification in fbdcfe8

c2rust-analyze/src/dataflow/mod.rs Outdated Show resolved Hide resolved
@aneksteind aneksteind force-pushed the feat.field.perms branch 2 times, most recently from 9a475bc to 9392a4f Compare October 15, 2023 21:14
@aneksteind aneksteind merged commit d21c267 into master Oct 15, 2023
9 checks passed
@aneksteind aneksteind deleted the feat.field.perms branch October 15, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants