Skip to content
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

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

Open
sapir opened this issue Sep 23, 2021 · 4 comments
Open

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

sapir opened this issue Sep 23, 2021 · 4 comments
Assignees
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@sapir
Copy link
Contributor

sapir commented Sep 23, 2021

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)
        ]
    );
}
@sapir sapir changed the title Like I said it depends on what the contract between swap_remove_and_drop_unchecked and its callers is. For example, the following program also prints drop 0 twice but replace_unchecked is never called. Panic in drop leads to a double drop on spawning a new entity Sep 23, 2021
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events labels Sep 23, 2021
@alice-i-cecile alice-i-cecile added the S-Needs-Investigation This issue requires detective work to figure out what's going wrong label Dec 12, 2021
@james7132
Copy link
Member

With #2848 merged, is this still an issue?

@sapir
Copy link
Contributor Author

sapir commented Feb 5, 2023

I updated the test code for current bevy. The test fails, it seems that object 0 is still being dropped twice.

@james7132 james7132 self-assigned this Feb 16, 2023
@james7132
Copy link
Member

Could I get the implementation of the DropLogItem and DropTestHelper here? Trying to investigate this.

@sapir
Copy link
Contributor Author

sapir commented Mar 5, 2024

Could I get the implementation of the DropLogItem and DropTestHelper here? Trying to investigate this.

enum DropLogItem {

struct DropTestHelper {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

3 participants