Skip to content

Panic in drop leads to a double drop on spawning a new entity #2860

Open
@sapir

Description

From #2597 (comment)

I think this happens due to Table::allocate increasing the column length before the data is actually written.

I also have a test for this, based on #2848

#[test]
fn panic_in_despawn_followed_by_insert() {
    let helper = DropTestHelper::new();

    let res = panic::catch_unwind(|| {
        let mut world = World::new();

        let e1 = world.spawn(helper.make_component(true, 0)).id();

        let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
            world.despawn(e1);
        }));

        world.spawn(helper.make_component(true, 1));

        println!("Done inserting! Dropping world...");
    });

    let drop_log = helper.finish(res);

    assert_eq!(
        &*drop_log,
        [
            DropLogItem::Create(0),
            DropLogItem::Drop(0),
            DropLogItem::Create(1),
            DropLogItem::Drop(1)
        ]
    );
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions