-
Notifications
You must be signed in to change notification settings - Fork 50
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
impl Trace for Rc<T> is not correct #134
Comments
What version are you using? |
Hmm, sorry for the preemptive closure. I still get the error when updated to 0.4 |
Now it's failing on lib.rs:125:9 Trying to run the same code paths via manually calling my binary (vs. in a test) causes "Can't double-unroot a Gc" in lib.rs:226. |
Are you using If not, you’ve probably found a new bug, and we’ll need to see some code that reproduces it to investigate further. |
Took me a couple tries to figure out exactly where the issue was coming from, but here's my reproduction: https://gist.github.com/lalaithion/125704f8f69408ec6d825b9075804787 |
Hmm. I was going to suggest that your use gc::Gc;
use std::rc::Rc;
fn main() {
let r = Rc::new(Gc::new(()));
Gc::new((Rc::clone(&r), r));
}
😕 |
As it is incorrect and can be a footgun Manishearth/rust-gc#134 Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
I’m not sure if these instances would work with a better tracing algorithm, but they do not work correctly with this one. let r = Rc::new(Gc::new(())); Gc::new((Rc::clone(&r), r)); // → thread 'main' panicked at 'Can't double-unroot a Gc<T>' Fixes Manishearth#134. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
I’m not sure if these instances would work with a better tracing algorithm, but they do not work correctly with this one. let r = Rc::new(Gc::new(())); Gc::new((Rc::clone(&r), r)); // → thread 'main' panicked at 'Can't double-unroot a Gc<T>' Fixes Manishearth#134. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
I’m not sure if these impls would work with a better tracing algorithm, but they do not work correctly with this one. let r = Rc::new(Gc::new(())); Gc::new((Rc::clone(&r), r)); // → thread 'main' panicked at 'Can't double-unroot a Gc<T>' Fixes Manishearth#134. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
The only unsafe code in my application is
(This is essentially a workaround for rpds not implementing Trace).
I've checked, and nothing in the rpds library implements Drop, so I don't see how I'm violating the Trace contract. Is this a bug, or am I missing some invariant I need to maintain?
The text was updated successfully, but these errors were encountered: