rust-lang / rust-lang/rust

ICE: stack overflow with instrument-coverage + gce

Open
#135,060 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-code-coverage C-bug F-generic_const_exprs I-crash P-low T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-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:

#![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

Program output

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

@rustbot label +F-generic_const_exprs

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 reduced a.rs with rustc -Cinstrument-coverage. The backtrace points to rustc_symbol_mangling's Printer::print_def_path, print_const, print_type, and print_impl_path; trace that recursion and verify the reduced example no longer overflows the stack or segfaults.

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.