rust-lang / rust-lang/rust

Encountering the type length limit ICEs Miri

Open
#127,699 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-eval C-bug I-ICE T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The following program ICEs Miri when invoked with -Zenforce-type-length-limit:

#![type_length_limit = "8"]
fn main() {}

Miri reports:

Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
note: the place in the program where the ICE was triggered
   --> /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:140:5
    |
140 |     panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_err(rt_abort)?;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: BACKTRACE:
    = note: inside `std::rt::lang_start_internal` at /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:140:5: 140:70
    = note: inside `std::rt::lang_start::<()>` at /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:158:17: 163:6

error: internal compiler error: src/tools/miri/src/diagnostics.rs:324:17: This error should be impossible in Miri: encountered overly generic constant

thread 'rustc' panicked at src/tools/miri/src/diagnostics.rs:324:17:
<backtrace to Miri's error reporting code, not relevant>

I'm filing this here because I'm pretty sure the problem is that the core interpreter logic does not handle the new failure path out of Instance::try_resolve correctly.

rustc 1.81.0-nightly (c6727fc9b 2024-07-12)
binary: rustc
commit-hash: c6727fc9b5c64cefa7263486497ee95e529bd0f8
commit-date: 2024-07-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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 with the minimal program in the issue and invoke Miri with -Zenforce-type-length-limit to reproduce the ICE. Read src/tools/miri/src/diagnostics.rs around line 324 and trace the failure path from Instance::try_resolve; done means this case no longer triggers an internal compiler error.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.