dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.25k stars 261 forks source link

thread panicked at 'Graph::add_edge: node indices out of bounds' #81

Closed Looooong closed 3 years ago

Looooong commented 3 years ago

I'm implementing a simple shooting mechanism using bullet with actual CCD-enabled rigid body and sensor collider. When I spawn a lots of bullet in a short time frame (ie. 15 bullets per 5 seconds) and each bullet despawn after 1 or 5 seconds after spawning, the app will panick. If I spawn bullets slowly, it won't panick. If I increase bullet lifespan to a very high value, it won't panic. It is possible that spawning and despawning multiple times in a short time causes panic.

Here is the app: https://github.com/Looooong/doce/tree/5b03c8839468b10bac926617a9581b409328839d

How to reproduce:

Here is the full trace:

thread 'main' panicked at 'Graph::add_edge: node indices out of bounds', C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\data\graph.rs:228:27
stack backtrace:
   0: std::panicking::begin_panic<str>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:519
   1: rapier3d::data::graph::Graph::add_edge<rapier3d::geometry::collider_components::ColliderHandle,bool>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\data\graph.rs:228
   2: rapier3d::geometry::interaction_graph::InteractionGraph::add_edge<rapier3d::geometry::collider_components::ColliderHandle,bool>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\geometry\interaction_graph.rs:44
   3: rapier3d::geometry::narrow_phase::NarrowPhase::add_pair<bevy_rapier3d::physics::collider_component_set::ColliderComponentsSet>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\geometry\narrow_phase.rs:594
   4: rapier3d::geometry::narrow_phase::NarrowPhase::register_pairs<bevy_rapier3d::physics::rigid_body_component_set::RigidBodyComponentsSet,bevy_rapier3d::physics::collider_component_set::ColliderComponentsSet>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\geometry\narrow_phase.rs:649
   5: rapier3d::pipeline::physics_pipeline::PhysicsPipeline::detect_collisions<bevy_rapier3d::physics::rigid_body_component_set::RigidBodyComponentsSet,bevy_rapier3d::physics::collider_component_set::ColliderComponentsSet>        
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\pipeline\physics_pipeline.rs:137
   6: rapier3d::pipeline::physics_pipeline::PhysicsPipeline::step_generic<bevy_rapier3d::physics::rigid_body_component_set::RigidBodyComponentsSet,bevy_rapier3d::physics::collider_component_set::ColliderComponentsSet>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.9.1\src\pipeline\physics_pipeline.rs:705
   7: bevy_rapier3d::physics::systems::step_world_system<tuple<>*>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_rapier3d-0.10.0\src\physics\systems.rs:313
   8: core::ops::function::Fn::call<fn(bevy_ecs::system::commands::Commands, tuple<bevy_ecs::system::system_param::Res<bevy_core::time::time::Time>, bevy_ecs::system::system_param::ResMut<bevy_rapier3d::physics::resources::SimulationToRenderTime>>, tuple<bevy_e
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:70
   9: core::ops::function::impls::{{impl}}::call_mut<tuple<bevy_ecs::system::commands::Commands, tuple<bevy_ecs::system::system_param::Res<bevy_core::time::time::Time>, bevy_ecs::system::system_param::ResMut<bevy_rapier3d::physics::resources::SimulationToRender
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:247
  10: bevy_ecs::system::into_system::{{impl}}::run<tuple<>,fn(bevy_ecs::system::commands::Commands, tuple<bevy_ecs::system::system_param::Res<bevy_core::time::time::Time>, bevy_ecs::system::system_param::ResMut<bevy_rapier3d::physics::resources::SimulationToRen
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\system\into_system.rs:207
  11: bevy_ecs::system::into_system::{{impl}}::run_unsafe<tuple<>,tuple<>,tuple<bevy_ecs::system::commands::Commands, tuple<bevy_ecs::system::system_param::Res<bevy_core::time::time::Time>, bevy_ecs::system::system_param::ResMut<bevy_rapier3d::physics::resource
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\system\into_system.rs:147
  12: bevy_ecs::schedule::executor_parallel::{{impl}}::prepare_systems::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\executor_parallel.rs:200
  13: core::future::from_generator::{{impl}}::poll<generator-0>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\future\mod.rs:80
  14: async_executor::{{impl}}::spawn::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\async-executor-1.4.1\src\lib.rs:144
  15: core::future::from_generator::{{impl}}::poll<generator-0>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\future\mod.rs:80
  16: async_task::raw::RawTask::run<core::future::from_generator::GenFuture<generator-0>,tuple<>,closure-0>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.0.3\src\raw.rs:489
  17: async_executor::Executor::try_tick
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\async-executor-1.4.1\src\lib.rs:181
  18: bevy_tasks::task_pool::{{impl}}::scope::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_tasks-0.5.0\src\task_pool.rs:222
  19: std::thread::local::LocalKey::try_with
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:272
  20: std::thread::local::LocalKey::with
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:248
  21: bevy_tasks::task_pool::TaskPool::scope<closure-1,tuple<>>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_tasks-0.5.0\src\task_pool.rs:169
  22: bevy_ecs::schedule::executor_parallel::{{impl}}::run_systems
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\executor_parallel.rs:121
  23: bevy_ecs::schedule::stage::{{impl}}::run
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\stage.rs:822
  24: bevy_ecs::schedule::Schedule::run_once
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:201
  25: bevy_ecs::schedule::{{impl}}::run
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:219
  26: bevy_winit::winit_runner_with::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.5.0\src\lib.rs:485
  27: winit::platform_impl::platform::event_loop::{{impl}}::run_return::{{closure}}<tuple<>,closure-1>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:203
  28: alloc::boxed::{{impl}}::call_mut
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:1553
  29: winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:245
  30: std::panic::{{impl}}::call_once<tuple<>,closure-0>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:344
  31: std::panicking::try::do_call
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:379
  32: std::panicking::try
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:343
  33: std::panic::catch_unwind
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:431
  34: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::catch_unwind
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:152
  35: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::call_event_handler<tuple<>>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:239
  36: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::move_state_to<tuple<>>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:303
  37: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::main_events_cleared
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:227
  38: winit::platform_impl::platform::event_loop::flush_paint_messages
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:676
  39: winit::platform_impl::platform::event_loop::thread_event_target_callback::{{closure}}
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:1967
  40: std::panic::{{impl}}::call_once<isize,closure-0>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:344
  41: std::panicking::try::do_call
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:379
  42: std::panicking::try
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:343
  43: std::panic::catch_unwind
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:431
  44: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::catch_unwind<tuple<>,isize,closure-0>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:152
  45: winit::platform_impl::platform::event_loop::thread_event_target_callback<tuple<>>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:2151
  46: DefSubclassProc
  47: DefSubclassProc
  48: CallWindowProcW
  49: DispatchMessageW
  50: SendMessageTimeoutW
  51: KiUserCallbackDispatcher
  52: NtUserDispatchMessage
  53: DispatchMessageW
  54: winit::platform_impl::platform::event_loop::EventLoop::run_return<tuple<>,closure-1>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:218
  55: winit::platform_impl::platform::event_loop::EventLoop::run<tuple<>,closure-1>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:188
  56: winit::event_loop::EventLoop::run<tuple<>,closure-1>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\event_loop.rs:154
  57: bevy_winit::run<closure-1>
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.5.0\src\lib.rs:171
  58: bevy_winit::winit_runner_with
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.5.0\src\lib.rs:493
  59: bevy_winit::winit_runner
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_winit-0.5.0\src\lib.rs:211
  60: core::ops::function::Fn::call<fn(bevy_app::app::App),tuple<bevy_app::app::App>>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:70
  61: alloc::boxed::{{impl}}::call
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:1560
  62: bevy_app::app::App::run
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app.rs:68
  63: bevy_app::app_builder::AppBuilder::run
             at C:\Users\duclo\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:49
  64: deterministic_online_coop_experiment::main
             at .\src\main.rs:40
  65: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\duclo\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
Looooong commented 3 years ago

Well, it is related to #75 . #78 fixes the issue for me.