Skip to content

Compilation unterminated when type variable is a huge array #118860

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

Closed
thomasyonug opened this issue Dec 12, 2023 · 3 comments · Fixed by #140504
Closed

Compilation unterminated when type variable is a huge array #118860

thomasyonug opened this issue Dec 12, 2023 · 3 comments · Fixed by #140504
Labels
C-bug Category: This is a bug. F-transmutability `#![feature(transmutability)]` I-compiletime Issue: Problems and improvements with respect to compile times. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@thomasyonug
Copy link

I tried this code:

// check-pass
#![feature(transmutability)]

mod assert {
    use std::mem::{Assume, BikeshedIntrinsicFrom};
    pub struct Context;

    pub fn is_maybe_transmutable<Src, Dst>()
    where
        Dst: BikeshedIntrinsicFrom<Src, Context, {
            Assume {
                alignment: false,
                lifetimes: false,
                safety: true,
                validity: false,
            }
        }>
    {}
}

fn main() {
    let a : &'static [u8; 32768];
    assert::is_maybe_transmutable::<&'static [u16; 32768], &'static [u8; 32768]>();
}

I expected to see this happen: compilation terminated

Instead, this happened: compilation unterminated

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (0288f2e19 2023-09-25)
binary: rustc
commit-hash: 0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa
commit-date: 2023-09-25
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0
Backtrace

nop

@thomasyonug thomasyonug added the C-bug Category: This is a bug. label Dec 12, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 12, 2023
@jswrenn
Copy link
Member

jswrenn commented Dec 12, 2023

Thanks for reporting this! Proving transmutability is complicated, and we don't yet optimize for large types. Supporting this is on our roadmap, but after a few other TODOs (like make BikeshedIntrinsicFrom sound).

@saethlin saethlin added F-transmutability `#![feature(transmutability)]` I-compiletime Issue: Problems and improvements with respect to compile times. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 12, 2023
@thomasyonug
Copy link
Author

Will this issue cause DOS attack?
I have checked this in the online rust playground, which set a threshold for compilation time to work around this issue.
Here is the link https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=2eacde8b3afebb747d3a3e9f25665436

@jswrenn
Copy link
Member

jswrenn commented Dec 13, 2023

While we do our best to avoid outrageously long compile times, rustc does not make any specific promises about performance, and it will always be possible to construct extremely hard-to-solve problems for inference and trait resolution. It's not considered a security issue, AFAIK.

@tmiasko tmiasko added the I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. label Apr 29, 2025
@bors bors closed this as completed in 62a48cd Apr 30, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 30, 2025
Rollup merge of rust-lang#140504 - tmiasko:answer-ensure-stack, r=jswrenn

transmutability: ensure_sufficient_stack when answering query

Based on rust-lang#140380.

Fixes rust-lang#118860. The compile time was addressed earlier, this merely addresses stack overflow part of the issue.

r? `@jswrenn` `@joshlf`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-transmutability `#![feature(transmutability)]` I-compiletime Issue: Problems and improvements with respect to compile times. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants