-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
World entity access is not sound #3408
Comments
There's a fix in #3001 |
Despite that, we may want a smaller, tightly scoped fix to this problem for now. |
Yup this is pretty heinous. Not pretty, but we could probably quickly fix this by making // we still don't return &mut Self, which makes misusing EntityMut via the "builder pattern" style harder
fn despawn(&mut self) {
self.invalid = true;
// despawn here
}
fn insert_bundle<B: Bundle>(&mut self, Bundle) -> &mut Self {
if self.invalid { panic!() }
// insert here
} |
But before rolling with that I'd like to consider #3001 first. |
This does not fix the let name = entity.get::<Name>().unwrap();
entity.remove::<Name>();
println!("{}", name.0); |
Groosssss. I suppose we could tighten the lifetimes by tying them to EntityMut's lifetime. |
Thats what #3001 does. |
Yes, that could work, as far as I can tell. |
Fixes bevyengine#3408 bevyengine#3001 also solves this but I dont see it getting merged any time soon so... # Objective make bevy ecs a lil bit less unsound ## Solution make `EntityMut::get_component_mut` return borrows from self instead of `'w`
Fixes bevyengine#3408 bevyengine#3001 also solves this but I dont see it getting merged any time soon so... # Objective make bevy ecs a lil bit less unsound ## Solution make `EntityMut::get_component_mut` return borrows from self instead of `'w`
Bevy version
0.5
Operating system & version
Windows 10
What you did
The World entity api allows use after free
What you expected to happen
The code should not compile
What actually happened
The code compiles without any errors or warnings
The text was updated successfully, but these errors were encountered: