image: panic while reading valid Jpeg image

This happens in image::open

Expected

No panic

Actual behaviour

Panic

Reproduction steps

image::open() the image from this url: https://cdn.aboutyou.de/file/90084b3edf1b97f95ca05c245721d554?width=2000&height=2000

produces this stack trace:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `2800000`,
 right: `2816000`: destination and source slices have different lengths', /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/macros/mod.rs:23:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:471
  11: rust_begin_unwind
             at src/libstd/panicking.rs:375
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:84
  13: core::slice::<impl [T]>::copy_from_slice
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/macros/mod.rs:21
  14: <image::jpeg::decoder::JpegDecoder<R> as image::image::ImageDecoder>::read_image
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/jpeg/decoder.rs:82
  15: image::image::decoder_to_vec
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/image.rs:293
  16: image::dynimage::decoder_to_image
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/dynimage.rs:878
  17: image::dynimage::DynamicImage::from_decoder
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/dynimage.rs:185
  18: image::io::free_functions::load
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/io/free_functions.rs:68
  19: image::io::free_functions::open_impl
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/io/free_functions.rs:51
  20: image::dynimage::open
             at /Users/kosta/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.23.0/./src/dynimage.rs:953
  21: image_panic::main
             at src/main.rs:2
  22: std::rt::lang_start::{{closure}}
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/rt.rs:67
  23: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  24: std::panicking::try::do_call
             at src/libstd/panicking.rs:292
  25: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  26: std::panicking::try
             at src/libstd/panicking.rs:270
  27: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  28: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  29: std::rt::lang_start
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/rt.rs:67
  30: image_panic::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Good news: I just used Cargo’s patch feature to confirm that the latest master of jpeg-decoder doesn’t have the issue anymore! (https://github.com/image-rs/jpeg-decoder.git#0920c4c506d2efbc58c5a1a03879e0eb66eb1200).

Sorry for being such a bad bug reporter - but thank you for fixing this bug!

Marking as fixed then, with release 0.1.19. Run cargo update -p jpeg-decoder to receive the fix.

I’m sorry this is an image from a german online shop that I tried to process. I don’t have any insights on their copyright.