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

thread 'main' panicked at 'Entity does not exist' #2668

Closed
mbaeten opened this issue Aug 17, 2021 · 2 comments
Closed

thread 'main' panicked at 'Entity does not exist' #2668

mbaeten opened this issue Aug 17, 2021 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@mbaeten
Copy link

mbaeten commented Aug 17, 2021

Thanks for your great work, very much appreciated. Glad to help if feasible.

I read the following: #1707, #1743, #2219

Bevy version

a1b2ec8 (bevy 0.5 from crates.io)

Operating system & version

NixOS Unstable

What you did

Created some plugins with systems running in parallel and/or serialized, only removing entites after they completed their work. Unfortunately, I'm not allowed to share the code itself. If it helps, I can try to create a MWE (if time permits).

What you expected to happen

Do not crash. Emit an error! if unavoidable.

What actually happened

thread 'main' panicked at 'Entity does not exist', ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/world/mod.rs:214:37

Additional information

thread 'main' panicked at 'Entity does not exist', ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/world/mod.rs:214:37
stack backtrace:
   0:     0x558f7b732af0 - std::backtrace_rs::backtrace::libunwind::trace::h34055254b57d8e79
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x558f7b732af0 - std::backtrace_rs::backtrace::trace_unsynchronized::h8f1e3fbd9afff6ec
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x558f7b732af0 - std::sys_common::backtrace::_print_fmt::h3a99a796b770c360
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x558f7b732af0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h32d1f94a80615d18
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x558f7b755a5c - core::fmt::write::h306731c068f7162c
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:1110:17
   5:     0x558f7b72d1f5 - std::io::Write::write_fmt::hd2fa90334eee2a21
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/io/mod.rs:1588:15
   6:     0x558f7b73501b - std::sys_common::backtrace::_print::h5abaa2601a852287
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x558f7b73501b - std::sys_common::backtrace::print::h8d81445442bb638f
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x558f7b73501b - std::panicking::default_hook::{{closure}}::hcfe804496a9fa747
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:208:50
   9:     0x558f7b734af1 - std::panicking::default_hook::hbea8e3ccf2ba8901
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:225:9
  10:     0x558f7b7356e4 - std::panicking::rust_panic_with_hook::h7ee9e1a2d0f8975a
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:622:17
  11:     0x558f7b7351c7 - std::panicking::begin_panic_handler::{{closure}}::h8ab3b4491718b2c7
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:519:13
  12:     0x558f7b732fec - std::sys_common::backtrace::__rust_end_short_backtrace::hd489062ffa586a9f
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x558f7b735129 - rust_begin_unwind
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
  14:     0x558f7a9669c1 - core::panicking::panic_fmt::hca6330e3e14086b4
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
  15:     0x558f7a9668b3 - core::option::expect_failed::hb6407502861d5eec
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/option.rs:1243:5
  16:     0x558f7b074588 - core::option::Option<T>::expect::hb4e136231f9b0421
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/option.rs:351:21
  17:     0x558f7abec978 - bevy_ecs::world::World::entity_mut::h6ae88df730e85fe1
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/world/mod.rs:214:9
  18:     0x558f7abe650c - <bevy_ecs::system::commands::Insert<T> as bevy_ecs::system::commands::Command>::write::h9e7944a392e954b9
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/commands.rs:351:9
  19:     0x558f7b545ffd - bevy_ecs::system::commands::CommandQueue::apply::h35982dcacdc6f745
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/commands.rs:24:13
  20:     0x558f7b546174 - <bevy_ecs::system::commands::CommandQueue as bevy_ecs::system::system_param::SystemParamState>::apply::h8ebccab4f78e6fdf
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/system_param.rs:458:9
  21:     0x558f7aad9af4 - <(P0,P1,P2,P3) as bevy_ecs::system::system_param::SystemParamState>::apply::h2f67c391feaa9dd5
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/system_param.rs:1010:19
  22:     0x558f7ab0aafe - <bevy_ecs::system::into_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::apply_buffers::h64f439c764bf4211
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/into_system.rs:161:9
  23:     0x558f7b514b87 - <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::hf5f93d4222fa3181
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/stage.rs:834:25
  24:     0x558f7b56a530 - bevy_ecs::schedule::Schedule::run_once::h2034ca144031b6fa
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/mod.rs:201:13
  25:     0x558f7b56a5a0 - <bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h412a9d3982b9759e
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/mod.rs:219:21
  26:     0x558f7b4bdbd8 - bevy_app::app::App::update::h0328d53a82ecaab6
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_app-0.5.0/src/app.rs:58:9
  27:     0x558f7b4bc4e0 - <bevy_app::schedule_runner::ScheduleRunnerPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::{{closure}}::hea28d49ac5a1a0c9
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_app-0.5.0/src/schedule_runner.rs:76:25
  28:     0x558f7b4bc8bd - <bevy_app::schedule_runner::ScheduleRunnerPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::h789e0a7e190c45aa
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_app-0.5.0/src/schedule_runner.rs:101:47
  29:     0x558f7b4af048 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4b7ce5908c896b6f
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/boxed.rs:1589:9
  30:     0x558f7b4bdcf1 - bevy_app::app::App::run::h116ccd77f6a71c7f
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_app-0.5.0/src/app.rs:68:9
  31:     0x558f7b4b633e - bevy_app::app_builder::AppBuilder::run::h27fd4f2a0189f1d7
                               at ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:49:9
  32:     0x558f7a96d0ca - my_project_name::main::h94e52035496abc6a
                               at ~/repos/my_project_name/src/main.rs:12:3
  33:     0x558f7a96ac3b - core::ops::function::FnOnce::call_once::h4caae3afd86d231c
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
  34:     0x558f7a96b4de - std::sys_common::backtrace::__rust_begin_short_backtrace::hb9d1c99edf362ba7
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:125:18
  35:     0x558f7a96b561 - std::rt::lang_start::{{closure}}::ha5bdfdc51a01a7b9
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/rt.rs:49:18
  36:     0x558f7b735be9 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2aabc384aab89b7b
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:259:13
  37:     0x558f7b735be9 - std::panicking::try::do_call::hc5fcacb7a85fc7b1
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:401:40
  38:     0x558f7b735be9 - std::panicking::try::hb5d9603af3abbe3a
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:365:19
  39:     0x558f7b735be9 - std::panic::catch_unwind::h98fe6ac3925e64b4
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:434:14
  40:     0x558f7b735be9 - std::rt::lang_start_internal::h22ac7383c516f93e
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/rt.rs:34:21
  41:     0x558f7a96b540 - std::rt::lang_start::ha3e6132f05793518
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/rt.rs:48:5
  42:     0x558f7a96d12c - main
  43:     0x7ff8afb2e780 - __libc_start_main
  44:     0x558f7a9671ba - _start
                               at /build/glibc-2.33/csu/../sysdeps/x86_64/start.S:120
  45:                0x0 - <unknown>
@mbaeten mbaeten added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Aug 17, 2021
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Aug 17, 2021
@alice-i-cecile
Copy link
Member

This looks the bug documented in #2581. Basically, the order that commands are applied in mirrors system order: your system order is likely ambiguous in critical ways and entities are being despawned before they exist.

That said, a more general solution is given by #2241, which pushes towards a safer, more customizable set of behaviours for Commands error handling. If you have the bandwidth, feedback (and perhaps contributions) on that thread would be valuable: I'd like to get the ball rolling on that again.

@alice-i-cecile
Copy link
Member

Closing as duplicate of #1743. Still important and useful to solve; it's just nice to try and keep the conversations centralized.

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 C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

2 participants