-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
World entity access is not sound #3408
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-HighThis is particularly urgent, and deserves immediate attentionThis is particularly urgent, and deserves immediate attention
Description
Bevy version
0.5
Operating system & version
Windows 10
What you did
The World entity api allows use after free
use bevy::prelude::*;
struct Name(String);
fn test(world: &mut World) {
let mut entity = world.spawn();
entity.insert(Name("Test".to_string()));
let name = entity.get::<Name>().unwrap();
entity.despawn(); // Or entity.remove::<Name>();
println!("{}", name.0); // This line should be a compile error
}
fn main() {
App::build()
.add_system(test.exclusive_system())
.run();
}What you expected to happen
The code should not compile
What actually happened
The code compiles without any errors or warnings
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-HighThis is particularly urgent, and deserves immediate attentionThis is particularly urgent, and deserves immediate attention