rust-lang / rust-lang/rust

Error when using image crate

Open
#132,240 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-incr-comp C-bug I-ICE S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

use std::{
    fs::{self, File},
    io::Write,
};

use image::ImageReader;

fn main() {
    println!("Hello, world!");

    image_from("planet.png")
}

fn image_from(path: &str) {
    let image_data = ImageReader::open(path)
        .expect("Cann't open image file")
        .decode()
        .expect("Can't decode image file");

    let mut image_log = File::create("image.txt").unwrap();

    let _ = image_log.write(image_data.as_bytes()).unwrap();
    // fs::write(imageLog, image_data)
}

OS: Windows 11
Rustup: 1.27.1
Cargo: 1.81.0

thread 'coordinator' panicked at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\compiler\rustc_codegen_ssa\src\back\write.rs:1676:29:
/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\compiler\rustc_codegen_ssa\src\back\write.rs:1676:29: worker thread panicked
stack backtrace:
   0:     0x7ffd9151408d - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffd9151408d - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffd9151408d - std::sys::backtrace::_print_fmt
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\sys\backtrace.rs:65
   3:     0x7ffd9151408d - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\sys\backtrace.rs:40
   4:     0x7ffd91544bb9 - core::fmt::rt::Argument::fmt
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\fmt\rt.rs:173
   5:     0x7ffd91544bb9 - core::fmt::write
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\fmt\mod.rs:1182
   6:     0x7ffd9150ab71 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\io\mod.rs:1827
   7:     0x7ffd91517127 - std::panicking::default_hook::closure$1
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs:269
   8:     0x7ffd91516d19 - std::panicking::default_hook
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs:296
   9:     0x7ffd6e2c2ed5 - memchr
  10:     0x7ffd9151796b - alloc::boxed::impl$50::call
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2084
  11:     0x7ffd9151796b - std::panicking::rust_panic_with_hook
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs:808
  12:     0x7ffd6f73a6ff - object[443503632d93082a]::elf::gnu_hash
  13:     0x7ffd6f7329f9 - object[443503632d93082a]::elf::gnu_hash
  14:     0x7ffd6f7217f3 - object[443503632d93082a]::elf::gnu_hash
  15:     0x7ffd6f7ce66d - rustc_middle[1ecd3c849d31efbc]::util::bug::bug_fmt
  16:     0x7ffd6f7aea6d - rustc_middle[1ecd3c849d31efbc]::ty::consts::const_param_default
  17:     0x7ffd6f7ae8ad - rustc_middle[1ecd3c849d31efbc]::ty::consts::const_param_default
  18:     0x7ffd6f7ce5a2 - rustc_middle[1ecd3c849d31efbc]::util::bug::bug_fmt
  19:     0x7ffd6cecf858 - rustc_interface[ce19ee65e5c643b1]::proc_macro_decls::proc_macro_decls_static
  20:     0x7ffd6a150ddd - llvm::DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyInfo,llvm::detail::DenseSetPair<llvm::StructType * __ptr64> >::~DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyIn
  21:     0x7ffd6a164c4f - llvm::DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyInfo,llvm::detail::DenseSetPair<llvm::StructType * __ptr64> >::~DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyIn
  22:     0x7ffd91528f0d - alloc::boxed::impl$48::call_once
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
  23:     0x7ffd91528f0d - alloc::boxed::impl$48::call_once
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
  24:     0x7ffd91528f0d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\sys\pal\windows\thread.rs:58
  25:     0x7ffe4b5e259d - BaseThreadInitThunk
  26:     0x7ffe4be0af38 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.81.0 (eeb90cda1 2024-09-04) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: cached cgu be5oc9yxgopg7ilp0e3j30unl should have an object file, but doesn't

Error told me to report t so here I am

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided image-crate example with Cargo on x86_64-pc-windows-msvc using rustc 1.81.0, then investigate the compiler panic in rustc_codegen_ssa and the reported incremental-compilation cache error. Done means identifying a reliable trigger and documenting or fixing the ICE with evidence from the supplied environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.