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 when removing boundary #31

Closed
rezural opened this issue Sep 26, 2021 · 1 comment · Fixed by #37
Closed

panic when removing boundary #31

rezural opened this issue Sep 26, 2021 · 1 comment · Fixed by #37

Comments

@rezural
Copy link
Contributor

rezural commented Sep 26, 2021

Is there anything I am doing wrong with this:

Removing a boundary, causes a panic.

Reproduction is here: https://github.com/rezural/salva/tree/panic-heightfield-boundaries

I changed the example heightfield3: rezural@0b94f1e#diff-6e95f7a94394df65d066f26ea4ce4087aa8caf504133160fef8dea6c01a75642

can be run with :

RUST_BACKTRACE=1 cargo run --release --features=parallel --bin all_examples3 -- --pause --example 'Height field'

basically:

#[derive(Clone, Copy)]
struct BoundaryHandles {
    collider: ColliderHandle,
    boundary: BoundaryHandle,
    body: RigidBodyHandle,
}

fn remove_boundary(
    handles: BoundaryHandles,
    fluids_pipeline: &mut FluidsPipeline,
    bodies: &mut RigidBodySet,
    colliders: &mut ColliderSet,
) {
    fluids_pipeline
        .coupling
        .unregister_coupling(handles.collider);

    fluids_pipeline
        .liquid_world
        .remove_boundary(handles.boundary);

    // bodies.remove(bodies);
}
removing previous boundaries
thread 'main' panicked at 'No element at index', build/salva3d/../../src/object/contiguous_arena.rs:128:13
stack backtrace:
  0: rust_begin_unwind
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
  1: core::panicking::panic_fmt
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
  2: core::option::expect_failed
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/option.rs:1578:5
  3: core::option::Option<T>::expect
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/option.rs:685:21
  4: <generational_arena::Arena<T> as core::ops::index::IndexMut<generational_arena::Index>>::index_mut
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/generational-arena-0.2.8/src/lib.rs:1305:9
  5: salva3d::object::contiguous_arena::ContiguousArena<Idx,T>::remove
            at /home/rezural/data/code/fluidsim/dm-examples/vendor/salva/build/salva3d/../../src/object/contiguous_arena.rs:128:13
  6: salva3d::liquid_world::LiquidWorld::remove_boundary
            at /home/rezural/data/code/fluidsim/dm-examples/vendor/salva/build/salva3d/../../src/liquid_world.rs:174:9
  7: all_examples3::heightfield3::remove_boundary
            at ./heightfield3.rs:110:5
  8: all_examples3::heightfield3::init_world::{{closure}}
            at ./heightfield3.rs:61:17
  9: <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1579:9
 10: <salva3d::integrations::rapier::testbed_plugin::FluidsTestbedPlugin as rapier_testbed3d::plugin::TestbedPlugin>::run_callbacks
            at /home/rezural/data/code/fluidsim/dm-examples/vendor/salva/build/salva3d/../../src/integrations/rapier/testbed_plugin.rs:315:13
 11: rapier_testbed3d::testbed::update_testbed
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier_testbed3d-0.10.0/src_testbed/testbed.rs:1164:17
 12: core::ops::function::Fn::call
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:70:5
 13: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:247:13
 14: <Func as bevy_ecs::system::into_system::SystemParamFunction<(),Out,(F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11),()>>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/into_system.rs:207:21
 15: <bevy_ecs::system::into_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/into_system.rs:147:19
 16: bevy_ecs::system::system::System::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/system/system.rs:48:18
 17: <bevy_ecs::schedule::executor::SingleThreadedExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/executor.rs:34:17
 18: <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/stage.rs:822:17
 19: bevy_ecs::schedule::Schedule::run_once
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/mod.rs:201:13
 20: <bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/schedule/mod.rs:219:21
 21: bevy_app::app::App::update
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app.rs:58:9
 22: bevy_winit::winit_runner_with::{{closure}}
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.5.0/src/lib.rs:485:17
 23: winit::platform_impl::platform::sticky_exit_callback
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:736:5
 24: winit::platform_impl::platform::x11::EventLoop<T>::run_return
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/x11/mod.rs:303:17
 25: winit::platform_impl::platform::x11::EventLoop<T>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/x11/mod.rs:398:9
 26: winit::platform_impl::platform::EventLoop<T>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:652:56
 27: winit::event_loop::EventLoop<T>::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/event_loop.rs:154:9
 28: bevy_winit::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.5.0/src/lib.rs:171:5
 29: bevy_winit::winit_runner_with
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.5.0/src/lib.rs:493:9
 30: bevy_winit::winit_runner
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.5.0/src/lib.rs:211:5
 31: core::ops::function::Fn::call
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:70:5
 32: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1586:9
 33: bevy_app::app::App::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app.rs:68:9
 34: bevy_app::app_builder::AppBuilder::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:49:9
 35: rapier_testbed3d::testbed::TestbedApp::run
            at /home/rezural/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier_testbed3d-0.10.0/src_testbed/testbed.rs:418:13
 36: all_examples3::main
            at ./all_examples3.rs:76:5
 37: core::ops::function::FnOnce::call_once
            at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Segmentation fault (core dumped)


@rezural
Copy link
Contributor Author

rezural commented Sep 29, 2021

I have isolated this into a unit test, which shows the problematic behaviour:

#33

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant