noise-rs icon indicating copy to clipboard operation
noise-rs copied to clipboard

Perlin noise panics

Open ctron opened this issue 2 years ago • 1 comments

Using a "too big" number (like the current milliseconds since the unix epoch) with the Perlin noise generator make it panic:

panicked at 'attempt to add with overflow', /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/arith.rs:108:1

Stack:

init/imports.wbg.__wbg_new_693216e109162396@http://localhost:8011/index-9c6c79c375859ff3.js:583:19
console_error_panic_hook::Error::new::h6c921ce5aa36eb8c@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[34737]:0x86c2dc
console_error_panic_hook::hook_impl::h94b68bdd6b00d8b2@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[3713]:0x41a03f
console_error_panic_hook::hook::hec1dc2fd053c9876@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[38870]:0x8a4317
core::ops::function::Fn::call::hadc55a8cd41688b7@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[31663]:0x83c102
std::panicking::rust_panic_with_hook::h12b2f0179ff84c92@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[8656]:0x586b4e
std::panicking::begin_panic_handler::{{closure}}::h5a69bb4aef967681@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[16284]:0x6d913a
std::sys_common::backtrace::__rust_end_short_backtrace::h1cfd7c1c16d2a171@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[45162]:0x8df7c1
rust_begin_unwind@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[36053]:0x87f08a
core::panicking::panic_fmt::hf0d93ec1ac504cf9@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[40203]:0x8b47c0
core::panicking::panic::h5d6906e2c1099660@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[31073]:0x832b17
<isize as core::ops::arith::Add>::add::h61b1bddf91598615@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[14617]:0x69e65b
core::ops::function::Fn::call::h590cbb0cfa4df367@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[25452]:0x7c9834
noise::math::zip_with2::h6bee9225d4bb4740@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[4379]:0x45a2ec
noise::math::add2::hc602188716dc4177@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[5911]:0x4d699c
<noise::noise_fns::generators::perlin::Perlin as noise::noise_fns::NoiseFn<[f64; 2]>>::get::h1b330c364b59a4f7@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[415]:0x157194
drogue_device_simulator::simulator::generators::noise::NoiseType::build::{{closure}}::h4b16df8c7409b404@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[23129]:0x795f67
<F as drogue_device_simulator::simulator::generators::noise::Noise>::get::h17afb8aade9e33e3@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[27157]:0x7ebefb
drogue_device_simulator::simulator::generators::noise::TweakableNoise::get::he6af139b66fd5e3d@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[14568]:0x69c8ec
<drogue_device_simulator::simulator::generators::noise::NoiseGenerator as drogue_device_simulator::simulator::generators::tick::TickedGenerator>::tick::h9eaf424e896261c5@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[232]:0xa5543
<drogue_device_simulator::simulator::generators::tick::TickingGenerator<G> as drogue_device_simulator::simulator::generators::Generator>::start::{{closure}}::h706e0c562e7dd195@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[374]:0x13b584
<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hf92e72dd176efa77@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[11817]:0x62c1d2
wasm_bindgen_futures::task::singlethread::Task::run::h384b2204452ba562@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[2690]:0x3a37b4
wasm_bindgen_futures::queue::QueueState::run_all::h7a0d776463b1f6ab@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[3242]:0x3e714f
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h43e0f5914c03d1a8@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[21786]:0x7753a7
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::ha1e52d27cf3b22cb@http://localhost:8011/index-9c6c79c375859ff3_bg.wasm:wasm-function[10325]:0x5e2db7
__wbg_adapter_60@http://localhost:8011/index-9c6c79c375859ff3.js:292:10
real@http://localhost:8011/index-9c6c79c375859ff3.js:203:20

I think that it is ok for the generator to fail (with a Result). But it should not panic.

ctron avatar Mar 22 '22 15:03 ctron

Do you have a minimum example for this? I'm using the Perlin noise from this crate in a project so I'd like to have a look into it

Piturnah avatar Dec 28 '22 11:12 Piturnah