Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering the type length limit ICEs Miri #127699

Open
saethlin opened this issue Jul 13, 2024 · 6 comments
Open

Encountering the type length limit ICEs Miri #127699

saethlin opened this issue Jul 13, 2024 · 6 comments
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

saethlin commented Jul 13, 2024

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
@saethlin saethlin added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Jul 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 13, 2024
@saethlin saethlin added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 14, 2024
@RalfJung
Copy link
Member

Seems like this leads to a TooGeneric?

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

Miri bails out on TooGeneric since it knows everything is monomorphized. (codegen does the same.) Does the type length limit cause TooGeneric errors? That would IMO be a wrong use of that error code, precisely because we have users that know that things are not generic any more so we should be able to distinguish errors they can see (like this type length limit) and errors they cannot see (like failing to compute the layout of a type due to generics).

@tiif
Copy link
Contributor

tiif commented Nov 27, 2024

I could reproduce this on:

rustc 1.81.0-nightly (5315cbe15 2024-07-11)
binary: rustc
commit-hash: 5315cbe15b79533f380bbb6685aa5480d5ff4ef5
commit-date: 2024-07-11
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

but could no longer reproduce on:

rustc 1.85.0-nightly (dff3e7ccd 2024-11-26)
binary: rustc
commit-hash: dff3e7ccd4a18958c938136c4ccdc853fcc86194
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Is this resolved?

@saethlin
Copy link
Member Author

saethlin commented Nov 29, 2024

Sounds resolved to me. If I manage to trip this again I'll file a new issue. Thanks for the gardening!

@theemathas
Copy link
Contributor

I can still reproduce the issue with the command RUSTFLAGS="-Zenforce-type-length-limit" cargo +nightly miri run

See #127670

Maybe this should be reopened?

@saethlin saethlin reopened this Nov 29, 2024
@tiif
Copy link
Contributor

tiif commented Nov 29, 2024

Ah makes sense. I didn't use -Zenforce-type-length-limit.

@RalfJung
Copy link
Member

Cc @compiler-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants