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

rapier3d PhysicsPipeline panic on step in /src/partitioning/qbvh/update.rs:367:54 #532

Closed
honnisha opened this issue Oct 8, 2023 · 4 comments · Fixed by dimforge/parry#185

Comments

@honnisha
Copy link

honnisha commented Oct 8, 2023

Rapier 3d version:
rapier3d = { version = "0.17.2", features = [ "simd-stable" ] }

I'm running this code:

    pub fn step(&mut self, physics_container: &PhysicsContainer) {
        let physics_hooks = ();
        let event_handler = ();
        self.physics_pipeline.step(
            &self.gravity,
            &self.integration_parameters,
            &mut physics_container.island_manager.write(),
            &mut self.broad_phase,
            &mut self.narrow_phase,
            &mut physics_container.rigid_body_set.write(),
            &mut physics_container.collider_set.write(),
            &mut self.impulse_joint_set,
            &mut self.multibody_joint_set,
            &mut self.ccd_solver,
            Some(&mut physics_container.query_pipeline.write()),
            &physics_hooks,
            &event_handler,
        );
    }

Panic:

thread '<unnamed>' panicked at 'attempt to add with overflow', /home/honnisha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parry3d-0.13.5/src/partitioning/qbvh/update.rs:367:54
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:117:5
   3: parry3d::partitioning::qbvh::update::<impl parry3d::partitioning::qbvh::qbvh::GenericQbvh<LeafData,parry3d::utils::array::DefaultStorage>>::rebalance
             at /home/honnisha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parry3d-0.13.5/src/partitioning/qbvh/update.rs:367:54
   4: rapier3d::pipeline::query_pipeline::QueryPipeline::update_incremental
             at /home/honnisha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rapier3d-0.17.2/src/pipeline/query_pipeline.rs:352:13
   5: rapier3d::pipeline::physics_pipeline::PhysicsPipeline::step
             at /home/honnisha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rapier3d-0.17.2/src/pipeline/physics_pipeline.rs:624:17
   6: honny_client::world::physics_handler::PhysicsController::step
             at /home/honnisha/godot/honny-craft/honny-client/src/world/physics_handler.rs:263:9
   7: honny_client::world::physics_handler::PhysicsContainer::step
             at /home/honnisha/godot/honny-craft/honny-client/src/world/physics_handler.rs:206:9
   8: <honny_client::world::godot_world::World as godot_core::gen::classes::node::re_export::NodeVirtual>::process
             at /home/honnisha/godot/honny-craft/honny-client/src/world/godot_world.rs:158:9
   9: <honny_client::world::godot_world::World as godot_core::obj::traits::cap::ImplementsGodotVirtual>::__virtual_call::function::{{closure}}
             at /home/honnisha/godot/honny-craft/honny-client/src/world/godot_world.rs:125:1
  10: core::ops::function::FnOnce::call_once
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/ops/function.rs:250:5
  11: <(R,P0) as godot_core::builtin::meta::signature::PtrcallSignatureTuple>::in_ptrcall
             at /home/honnisha/.cargo/git/checkouts/gdext-76630c89719e160c/a92164b/godot-core/src/builtin/meta/signature.rs:274:38
  12: <honny_client::world::godot_world::World as godot_core::obj::traits::cap::ImplementsGodotVirtual>::__virtual_call::function
             at /home/honnisha/godot/honny-craft/honny-client/src/world/godot_world.rs:125:1
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: __libc_start_main
  22: <unknown>

Maybe its related to #450

@Ralith
Copy link
Contributor

Ralith commented Oct 14, 2023

Just hit this myself, in connection with a body going from dynamic to kinematic, and the reverse.

@honnisha
Copy link
Author

I'm trying to figure out what the cause is. I have added logs before the line where error occurs

parry/src/partitioning/qbvh/update.rs

                    if child < self.nodes.len() as u32 {
                        if depth == u8::MAX {
                            println!("workspace.stack.len():{} child:{} depth:{}", workspace.stack.len(), child, depth);
                        }
                        workspace.stack.push((child, depth + 1));
                    }

Output:

workspace.stack.len():8 child:7917 depth:255
thread '<unnamed>' panicked at /home/honnisha/Projects/parry/crates/parry3d/../../src/partitioning/qbvh/update.rs:370:54:

My code switches activity of the colliders if the player moves forward/away from them. And right after the switch this error occurs sometimes.

@honnisha
Copy link
Author

Created pr to fix this issue
dimforge/parry#169

@Ralith
Copy link
Contributor

Ralith commented Oct 16, 2023

Why would changing a rigid body type require an unusually large stack depth? I suspect the stack size might be a symptom of a more basic issue.

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.

2 participants