PistonDevelopers/resize

Point resizer causes panic

surma opened this issue · 1 comments

surma commented

(Sorry to be pain)

Constructing a Resizer using Type::Point causes a panics. The data type seems to be irrelevant.

let resizer = resize::new(10, 10, 5, 5, resize::Pixel::RGBF64, resize::Type::Point);
thread 'main' panicked at 'attempt to subtract with overflow', /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:276:24

Full backtrace:

warning: unused variable: `resizer`
 --> reproduction.rs:4:9
  |
4 |     let resizer = resize::new(10, 10, 5, 5, resize::Pixel::RGBF64, resize::Type::Point);
  |         ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_resizer`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/reproduction`
thread 'main' panicked at 'attempt to subtract with overflow', /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:276:24
stack backtrace:
   0:     0x55a61bccb9d5 - backtrace::backtrace::libunwind::trace::ha215bbf14e328799
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x55a61bccb9d5 - backtrace::backtrace::trace_unsynchronized::h3384b099b135857a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x55a61bccb9d5 - std::sys_common::backtrace::_print_fmt::hfec93740f7294682
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x55a61bccb9d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5fe20777f4174074
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x55a61bce8e1c - core::fmt::write::he14c3177144df275
                               at src/libcore/fmt/mod.rs:1076
   5:     0x55a61bcca183 - std::io::Write::write_fmt::h8e26323bfab8bcc5
                               at src/libstd/io/mod.rs:1537
   6:     0x55a61bccdee0 - std::sys_common::backtrace::_print::h9cfa4c87526ba064
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x55a61bccdee0 - std::sys_common::backtrace::print::h94936584848b3272
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x55a61bccdee0 - std::panicking::default_hook::{{closure}}::h733b20cc9b496e46
                               at src/libstd/panicking.rs:198
   9:     0x55a61bccdc2c - std::panicking::default_hook::h556d8cff6c12a651
                               at src/libstd/panicking.rs:218
  10:     0x55a61bcce4c7 - std::panicking::rust_panic_with_hook::ha0c7ca5b39baa9d5
                               at src/libstd/panicking.rs:486
  11:     0x55a61bcce0cb - rust_begin_unwind
                               at src/libstd/panicking.rs:388
  12:     0x55a61bce8221 - core::panicking::panic_fmt::h106d7128cbbc7cd2
                               at src/libcore/panicking.rs:101
  13:     0x55a61bce816d - core::panicking::panic::hfe03c118d2519816
                               at src/libcore/panicking.rs:56
  14:     0x55a61bcb3224 - resize::Scale::calc_coeffs::{{closure}}::h61f5a9330b01a84c
                               at /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:276
  15:     0x55a61bcb58e4 - core::iter::adapters::map_fold::{{closure}}::h738bafb4f2f0b46e
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/iter/adapters/mod.rs:830
  16:     0x55a61bcc1489 - core::iter::traits::iterator::Iterator::fold::hea9904c9229888d3
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/iter/traits/iterator.rs:2022
  17:     0x55a61bcb60af - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::hb1eda643160212d0
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/iter/adapters/mod.rs:870
  18:     0x55a61bcb5161 - core::iter::traits::iterator::Iterator::for_each::h04a99aa8060cf773
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/iter/traits/iterator.rs:658
  19:     0x55a61bcbb35a - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::spec_extend::hce7165bcd48910d2
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/liballoc/vec.rs:2123
  20:     0x55a61bcbb583 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::h5919cd6a32aa7a91
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/liballoc/vec.rs:2103
  21:     0x55a61bcbb72c - <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter::h681b2ce6fc069fd7
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/liballoc/vec.rs:1978
  22:     0x55a61bcb502b - core::iter::traits::iterator::Iterator::collect::h0a8bf9532a810f06
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/iter/traits/iterator.rs:1671
  23:     0x55a61bcb280c - resize::Scale::calc_coeffs::h0852135b9347a4b7
                               at /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:269
  24:     0x55a61bcb2177 - resize::Scale::new::h24ae0b59a427257c
                               at /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:249
  25:     0x55a61bcb1a6b - resize::Resizer<Format>::new::h68c33d4915652af3
                               at /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:304
  26:     0x55a61bcb1934 - resize::new::h6ee67d51cdeed694
                               at /home/surma/.cargo/registry/src/github.com-1ecc6299db9ec823/resize-0.5.2/src/lib.rs:380
  27:     0x55a61bcb1934 - reproduction::main::h1537b3ffcd774c39
                               at /home/surma/src/scratch/resizebug/reproduction.rs:4
  28:     0x55a61bcb1b7b - std::rt::lang_start::{{closure}}::hb1021b93b5eb6fa7
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/rt.rs:67
  29:     0x55a61bcce898 - std::rt::lang_start_internal::{{closure}}::hefb489d56a389b75
                               at src/libstd/rt.rs:52
  30:     0x55a61bcce898 - std::panicking::try::do_call::hb2bfa58b743656f1
                               at src/libstd/panicking.rs:297
  31:     0x55a61bcce898 - std::panicking::try::haaa85a89ce3784c3
                               at src/libstd/panicking.rs:274
  32:     0x55a61bcce898 - std::panic::catch_unwind::h49baa277f74e60cb
                               at src/libstd/panic.rs:394
  33:     0x55a61bcce898 - std::rt::lang_start_internal::h7aa2f6739b31fe58
                               at src/libstd/rt.rs:51
  34:     0x55a61bcb1b57 - std::rt::lang_start::hd531e43acc62b0d2
                               at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/rt.rs:67
  35:     0x55a61bcb197a - main
  36:     0x7f137c36e002 - __libc_start_main
  37:     0x55a61bcb116e - _start
  38:                0x0 - <unknown>

Thanks. Fixed in dd25209