-
-
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
Drop called multiple times if drop panics. #2597
Comments
Only bevy/crates/bevy_ecs/src/storage/blob_vec.rs Lines 101 to 106 in 43d99bb
bevy/crates/bevy_ecs/src/storage/blob_vec.rs Lines 160 to 164 in 43d99bb
bevy/crates/bevy_ecs/src/storage/blob_vec.rs Lines 183 to 196 in 43d99bb
|
It depends on what the callers do. In the code path I've looked at, the entity is removed from the world before drop is called. So there is no problem. Without the additional knowledge that |
|
Like I said it depends on what the contract between use bevy::prelude::*;
struct Dropper(i32);
impl Drop for Dropper {
fn drop(&mut self) {
println!("drop {}", self.0);
if self.0 == 0 {
panic!();
}
}
}
fn main() {
let mut world = World::new();
let e1 = world.spawn().insert(Dropper(0)).id();
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
world.despawn(e1);
}));
world.spawn().insert(Dropper(1)).id();
} |
That did be a bug in |
Bevy version
Master
Operating system & version
Arch Linux
What you did
What you expected to happen
drop 0
is printed at most once.What actually happened
drop 0
is printed twice.Additional information
Several functions in https://github.com/bevyengine/bevy/blob/43d99bb583866c1adb4aa88f19b88637df0a7f33/crates/bevy_ecs/src/storage/blob_vec.rs do not handle
self.drop
unwinding (nor require their callers to do so.)The text was updated successfully, but these errors were encountered: