-
Notifications
You must be signed in to change notification settings - Fork 85
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
[Discussion] Abstract heap #18
Comments
The Path -> AbstractValue map is my current guess of what is needed to model the heap, but you are probably right to question if this is going to be sufficient. Two big questions that still need answering are:
|
I'm suspicious that we can't, since it is valid that some variable on stack is a reference/clone of another (i.e. two pointer value alias). I think instead of being In this abstraction, it is okay for two |
I am not sure about the frequency or the amount of computation needed, only guessing that this is minimal in user code. We can optimize that anyway in future I think. |
There's at least one case where this is violated: In any case, here's a program that uses
|
You will need to enforce them explicitly, e.g. use std::cell::RefCell;
struct MutableOnTheInside {
f: RefCell<u64>,
}
// if s1 and s2 alias, there will be two writes to the same memory via distinct access paths
// s1.f and s2.f
fn foo(s1: &MutableOnTheInside, s2: &MutableOnTheInside) {
let bor = s1.f.borrow_mut();
*s2.f.borrow_mut() = 2;
*bor = 3; // panics!
}
fn main() {
let s = MutableOnTheInside { f: RefCell::new(0) };
foo(&s, &s);
println!("{:?}", s.f);
} |
I suspect that the only reasonable way to deal with this is to check call sites for aliasing. So, at the call foo(&s, &s) one could use the summary to detect that s1 is actually modified and therefore complain if it is also aliased. Looking at the implementation of replace, it seems likely that things will not work well (or at all) unless replace is custom summarized. Let's see how things pan out. |
I think we need an abstract model of heap. What is on your mind? @hermanventer
Another question to clarify is how to abstract heap pointer values, a.k.a.
Box<T>
. Is there another wrapper of heap-allocated object in Rust?I checked the source and there is only
pub environment: &'a mut HashTrieMap<Path, AbstractValue>
.The text was updated successfully, but these errors were encountered: