dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.93k stars 244 forks source link

Crash while updating the query pipeline #450

Closed sconybeare closed 5 months ago

sconybeare commented 1 year ago

Running this example with debug asserts enabled crashes with an integer overflow during the call to state.step() while the query pipeline is updated.

The panic message is:

$ RUST_BACKTRACE=1 cargo r
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target\debug\rapier2d-panic-repro.exe`
[src\main.rs:148] num_blocks = 900
thread 'main' panicked at 'attempt to add with overflow', C:\Users\<USER>\.cargo\registry\src\github.com-1ecc6299db9ec823\parry2d-0.13.0\src\partitioning\qbvh\update.rs:359:54
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library\core\src\panicking.rs:65
   2: core::panicking::panic
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library\core\src\panicking.rs:115
   3: parry2d::partitioning::qbvh::qbvh::GenericQbvh<rapier2d::geometry::collider_components::ColliderHandle,parry2d::utils::array::DefaultStorage>::rebalance<rapier2d::geometry::collider_components::ColliderHandle>
             at C:\Users\<USER>\.cargo\registry\src\github.com-1ecc6299db9ec823\parry2d-0.13.0\src\partitioning\qbvh\update.rs:359
   4: rapier2d::pipeline::query_pipeline::QueryPipeline::update_incremental
             at C:\Users\<USER>\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier2d-0.17.1\src\pipeline\query_pipeline.rs:352
   5: rapier2d::pipeline::physics_pipeline::PhysicsPipeline::step
             at C:\Users\<USER>\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier2d-0.17.1\src\pipeline\physics_pipeline.rs:624
   6: rapier2d_panic_repro::State::step
             at .\src\main.rs:64
   7: rapier2d_panic_repro::main
             at .\src\main.rs:156
   8: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6\library\core\src\ops\function.rs:251
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\rapier2d-panic-repro.exe` (exit code: 101)
eldyer commented 1 year ago

Confirming this, and it also applies to parry3d since (I think) 0.13.

wlinna commented 1 year ago

This happens to me with 0.13.0 in my application. Update runs for minutes, and then finally crashes with this same error in the same line of code.

Ralith commented 1 year ago

Just hit this in parry3d-f64 0.13.5.