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

[PDG] Strong updates to mutable references don't seem to work. #90

Open
JustusAdam opened this issue Feb 1, 2024 · 1 comment
Open

Comments

@JustusAdam
Copy link
Contributor

JustusAdam commented Feb 1, 2024

I tried code equivalent to this

let mut user_data = Vec::new();
user_data.push(0);
send(&user_data);

What I expected is that the vector connects to the first argument of push and then to the first argument of send. Instead there is an additional direct connection from the initial vector to the first argument of send.

The same actually happens with return values too.

let mut user_data = Vec::new();
let r = user_data.deref();
send(r);

This also has a direct connection between the vector and send, despite the code clearly always going through deref.

@JustusAdam
Copy link
Contributor Author

Actually after some experimentation it sems to also happen with immutable references which is strange to me? This is the code I analyzed:

fn main() {
    let s = new_s();
    // 'a : 'b
    let t = deref_t(&s);
    read(t);
}

// Type signatures for external functions
fn deref_t(s: &S) -> &String;
fn read<T>(t: &T);
fn new_s() -> S;

The result has an edge from s to the first argument of read which I believe it shouldn't. It is not possible for any part of s to reach that place without passing through/being selected by deref_t.

JustusAdam added a commit to brownsys/paralegal that referenced this issue Feb 21, 2024
## What Changed?

- Data and control flow graph construction moves into the Flowistry
crate.
- Removes `df`, inlining logic and the algebra.
- Entails an update of the rustc toolchain (to achieve parity with
flowistry).
- Graph contains all program locations, not just function calls.
- Control flow is non-transitive
- The PDG now tracks individual places instead of abstract function
arguments. This improves field sensitivity across function calls.
- Forge output is gone

## Why Does It Need To?

Field sensitivity is now handled as the initial analysis constructs the
PDG and in fewer lines of code.

## Caveats

At the time of this merge, the following regressions in the PDG have not
been fixed yet

- willcrichton/flowistry#95
- willcrichton/flowistry#94
- willcrichton/flowistry#93
- And while Will fixed the strong updates
willcrichton/flowistry#90 the second issue
mentioned there is still present.

## Checklist

- [x] Above description has been filled out so that upon quash merge we
have a
  good record of what changed.
- [x] New functions, methods, types are documented. Old documentation is
updated
  if necessary
- [ ] Documentation in Notion has been updated
- [ ] Tests for new behaviors are provided
  - [ ] New test suites (if any) ave been added to the CI tests (in
`.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.
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

No branches or pull requests

1 participant