Repository: rust
Issue: ICE: stack overflow with instrument-coverage + gce
Labels: I-crash,T-compiler,C-bug,F-generic_const_exprs,A-code-coverage

<!--
[31mICE[0m: Rustc ./a.rs '-Cinstrument-coverage -ooutputfile -Zdump-mir-dir=dir' 'error: rustc interrupted by SIGSEGV, printing backtrace', 'error: rustc interrupted by SIGSEGV, printing backtrace'
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
//@compile-flags: -Cinstrument-coverage

#![feature(generic_const_exprs)]

struct GenericStruct<const T: usize> { val: i64 }

impl<const T: usize> From<GenericStruct<T>> for GenericStruct<{T + 1}> {
    fn from(other: GenericStruct<T>) -> Self {
        Self { val: other.val }
    }
}

impl<const T: usize> From<GenericStruct<{T + 1}>> for GenericStruct<T> {
    fn from(other: GenericStruct<{T + 1}>) -> Self {
        Self { val: other.val }
    }
}

pub fn main() {}
````

original:
````rust
#![feature(generic_const_exprs)]

struct GenericStruct<const T: usize> { val: i64 }

impl<const T: usize> From<GenericStruct<T>> for GenericStruct<{T + 1}> {
    fn from(other: GenericStruct<T>) -> Self {
        Self { val: other.val }
    }
}

impl<const T: usize> From<GenericStruct<{T + 1}>> for GenericStruct<T> {
    fn from(other: GenericStruct<{T + 1}>) -> Self {
        Self { val: other.val }
    }
}

pub fn main() {}

````

Version information
````
rustc 1.85.0-nightly (870c13dc9 2025-01-03)
binary: rustc
commit-hash: 870c13dc9b85944ceb172df54c7b1c615a46cb6e
commit-date: 2025-01-03
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

````



Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc -Cinstrument-coverage`

<details><summary><strong>Program output</strong></summary>
<p>

```
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> a.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: rustc interrupted by SIGSEGV, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x36683f3) [0x795f7a0683f3]
/usr/lib/libc.so.6(+0x3d1d0) [0x795f7684c1d0]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x57273a3) [0x795f7c1273a3]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x41b28d7) [0x795f7abb28d7]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x57273a8) [0x795f7c1273a8]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x5726b18) [0x795f7c126b18]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x525) [0x795f7abb7a95]

### cycle encountered after 7 frames with period 14
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x835) [0x795f7abb7da5]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer11print_const+0x7f9) [0x795f7abb98c9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x41ba59a) [0x795f7abba59a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x89f) [0x795f7abb7e0f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer10print_type+0x3ab) [0x795f7abb891b]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer15print_impl_path+0x4f9) [0x795f7abb83f9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x134) [0x795f7abb76a4]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x835) [0x795f7abb7da5]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer11print_const+0x7f9) [0x795f7abb98c9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x41ba59a) [0x795f7abba59a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x89f) [0x795f7abb7e0f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer10print_type+0x3ab) [0x795f7abb891b]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer15print_impl_path+0x4f9) [0x795f7abb83f9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x134) [0x795f7abb76a4]
### recursed 17 times

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x835) [0x795f7abb7da5]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer11print_const+0x7f9) [0x795f7abb98c9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x41ba59a) [0x795f7abba59a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x89f) [0x795f7abb7e0f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer10print_type+0x3ab) [0x795f7abb891b]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer15print_impl_path+0x4f9) [0x795f7abb83f9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x134) [0x795f7abb76a4]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x835) [0x795f7abb7da5]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer11print_const+0x7f9) [0x795f7abb98c9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(+0x41ba59a) [0x795f7abba59a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-78e18ca94582029e.so(_RNvXs_NtCs9IDk8BqyfS6_21rustc_symbol_mangling2v0NtB4_13SymbolManglerNtNtNtCseKm81Dn2gJ6_12rustc_middle2ty5print7Printer14print_def_path+0x89f) [0x795f7abb7e0f]

note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
[1]    1549998 segmentation fault  rustc a.rs -Cinstrument-coverage
```

</p>
</details>

<!--
query stack:

-->
@rustbot label +F-generic_const_exprs