Uh oh!
There was an error while loading. Please reload this page.
Doc: remove a "safety note" made obsolete by dropck for TypedArena - #24282
Conversation
rust-highfive
commented
Apr 10, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
pnkfelix
commented
Apr 10, 2015
@bors r+ rollup |
bors
commented
Apr 10, 2015
📌 Commit c2fa1f7 has been approved by |
SimonSapin
commented
Apr 12, 2015
@pnkfelix, thinking about this a bit more, I was wondering if dropck really applied here or if unsoundess was still possible with So I tried to see if I could deliberately cause a use-after-free in safe code: #![feature(rustc_private)]externcrate arena;use std::cell::Cell;structFoo<'a>{data:Box<u32>,other:Cell<Option<&'aFoo<'a>>>}impl<'a>DropforFoo<'a>{fndrop(&mutself){let other = self.other.get().unwrap();println!("Accessing other item’s data = {}",*other.data);// Use after free?println!("Dropping with data = {}",*self.data);}}fnmain(){let arena = arena::TypedArena::new();// Create a reference cycle within the arena:let a = arena.alloc(Foo{data:Box::new(42),other:Cell::new(None),});let b = arena.alloc(Foo{data:Box::new(6),other:Cell::new(None)});
a.other.set(Some(b));
b.other.set(Some(a));}This fails to compile with Just because I didn’t manage to find a problem doesn’t prove it doesn’t exist, but I’m slightly more confident about removing this warning now. |
https://botbot.me/mozilla/rust-internals/2015-04-10/?msg=36316959&page=6