Skip to content

ICE with adt_const_params and instrument-coverage #97625

Not planned
@mikialex

Description

@mikialex

Run the following code with rustc -Cinstrument-coverage ./test.rs cause ICE.

Code

#![feature(adt_const_params)]
#![allow(incomplete_features)]

fn eval<const N: f32>() -> f32 {
  N
}

fn main() {
  println!("{}", eval::<0.5>());
}

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (e09449220 2022-05-31)
binary: rustc
commit-hash: e0944922007e1bb4fe59809293acf4364410cccc
commit-date: 2022-05-31
host: x86_64-pc-windows-msvc
release: 1.63.0-nightly
LLVM version: 14.0.4

Error output

error: internal compiler error: compiler\rustc_symbol_mangling\src\v0.rs:728:17: symbol_names: unsupported constant of type `f32` (Const { ty: f32, val: Value(Scalar(0x3f000000)) 
})

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e0944922007e1bb4fe59809293acf4364410cccc\compiler\rustc_errors\src\lib.rs:1335:9
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (e09449220 2022-05-31) running on x86_64-pc-windows-msvc

note: compiler flags: -C instrument-coverage

query stack during panic:
#0 [symbol_name] computing the symbol for `eval::<0.5f32>`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

Backtrace


thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e0944922007e1bb4fe59809293acf4364410cccc\compiler\rustc_errors\src\lib.rs:1335:9
stack backtrace:
   0:     0x7ffc1e6d9baf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h29008f0d8360991f
   1:     0x7ffc1e714baa - core::fmt::write::h8a73e3be4bf01465
   2:     0x7ffc1e6cbfa9 - <std::io::IoSlice as core::fmt::Debug>::fmt::h5b68e796365090b2
   3:     0x7ffc1e6dd49b - std::panicking::default_hook::h9a42856a3bf2d779
   4:     0x7ffc1e6dd11b - std::panicking::default_hook::h9a42856a3bf2d779
   5:     0x7ffbf6a9dd96 - <rustc_metadata[f47eeeeabaa7db06]::rmeta::encoder::EncodeContext as rustc_serialize[ec78526cf068bb80]::serialize::Encoder>::emit_raw_bytes
   6:     0x7ffc1e6ddc42 - std::panicking::rust_panic_with_hook::h7fa68a9e3338055f
   7:     0x7ffbfaf50d25 - <rustc_middle[608b18733af6f849]::ty::closure::BorrowKind as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
   8:     0x7ffbfaf4fb89 - <rustc_middle[608b18733af6f849]::ty::closure::BorrowKind as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
   9:     0x7ffbfb5665c9 - rustc_middle[608b18733af6f849]::util::bug::bug_fmt
  10:     0x7ffbfb05b9d9 - <rustc_middle[608b18733af6f849]::ty::sty::TypeAndMut as rustc_middle[608b18733af6f849]::ty::context::Lift>::lift_to_tcx
  11:     0x7ffbfb042383 - <rustc_middle[608b18733af6f849]::ty::sty::TypeAndMut as rustc_middle[608b18733af6f849]::ty::context::Lift>::lift_to_tcx
  12:     0x7ffbfb0400b2 - <rustc_middle[608b18733af6f849]::ty::sty::TypeAndMut as rustc_middle[608b18733af6f849]::ty::context::Lift>::lift_to_tcx
  13:     0x7ffbfb0167a9 - <rustc_middle[608b18733af6f849]::ty::consts::valtree::ValTree>::zst
  14:     0x7ffbfb01682c - <rustc_middle[608b18733af6f849]::ty::consts::valtree::ValTree>::zst
  15:     0x7ffbfb565ae8 - rustc_middle[608b18733af6f849]::util::bug::bug_fmt
  16:     0x7ffbfa4dd74d - <&mut rustc_symbol_mangling[7008d1b4a8560b2c]::v0::SymbolMangler as rustc_middle[608b18733af6f849]::ty::print::Printer>::print_const
  17:     0x7ffbfa4de006 - <&mut rustc_symbol_mangling[7008d1b4a8560b2c]::v0::SymbolMangler as rustc_middle[608b18733af6f849]::ty::print::Printer>::path_qualified
  18:     0x7ffbfa4d8c31 - <&mut rustc_symbol_mangling[7008d1b4a8560b2c]::v0::SymbolMangler as rustc_middle[608b18733af6f849]::ty::print::Printer>::print_def_path
  19:     0x7ffbfa4d6fa9 - rustc_symbol_mangling[7008d1b4a8560b2c]::typeid_for_fnabi
  20:     0x7ffbfa4d5d3d - rustc_symbol_mangling[7008d1b4a8560b2c]::provide
  21:     0x7ffbfa2ade22 - <&[rustc_middle[608b18733af6f849]::thir::abstract_const::Node] as rustc_serialize[ec78526cf068bb80]::serialize::Decodable<rustc_query_impl[300e2971295ed741]::on_disk_cache::CacheDecoder>>::decode
  22:     0x7ffbf9f5d375 - <rustc_query_impl[300e2971295ed741]::Queries as rustc_middle[608b18733af6f849]::ty::query::QueryEngine>::try_mark_green
  23:     0x7ffbfb020c4e - <rustc_middle[608b18733af6f849]::mir::mono::MonoItem>::symbol_name
  24:     0x7ffbf8ff606e - <rustc_monomorphize[b3a1078a39399015]::partitioning::MonoItemPlacement as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
  25:     0x7ffbf8fe606f - <rustc_monomorphize[b3a1078a39399015]::collector::MirNeighborCollector as rustc_middle[608b18733af6f849]::mir::visit::Visitor>::visit_operand
  26:     0x7ffbf8fcd54b - <tracing_subscriber[86062e48cce79c6b]::util::TryInitError as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
  27:     0x7ffbf8fed13c - <rustc_monomorphize[b3a1078a39399015]::partitioning::MonoItemPlacement as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
  28:     0x7ffbf8fe65c0 - <rustc_monomorphize[b3a1078a39399015]::collector::MirNeighborCollector as rustc_middle[608b18733af6f849]::mir::visit::Visitor>::visit_operand
  29:     0x7ffbfa24e489 - <&[rustc_middle[608b18733af6f849]::thir::abstract_const::Node] as rustc_serialize[ec78526cf068bb80]::serialize::Decodable<rustc_query_impl[300e2971295ed741]::on_disk_cache::CacheDecoder>>::decode
  30:     0x7ffbfa2f3427 - <&[rustc_middle[608b18733af6f849]::thir::abstract_const::Node] as rustc_serialize[ec78526cf068bb80]::serialize::Decodable<rustc_query_impl[300e2971295ed741]::on_disk_cache::CacheDecoder>>::decode
  31:     0x7ffbf9f5dfd1 - <rustc_query_impl[300e2971295ed741]::Queries as rustc_middle[608b18733af6f849]::ty::query::QueryEngine>::try_mark_green
  32:     0x7ffbf6cbcff5 - <rustc_codegen_llvm[dab98a06ece5d8b2]::back::lto::ThinData as core[1b81ed6b3b69d0c3]::ops::drop::Drop>::drop
  33:     0x7ffbf6c582c5 - <rustc_codegen_llvm[dab98a06ece5d8b2]::LlvmCodegenBackend as rustc_codegen_ssa[cc51a84129a2d87c]::traits::backend::CodegenBackend>::codegen_crate       
  34:     0x7ffbf6b9a272 - <rustc_interface[713bcfa795747777]::queries::Linker>::link
  35:     0x7ffbf6b9497e - <rustc_interface[713bcfa795747777]::queries::Queries>::ongoing_codegen
  36:     0x7ffbf6a34ee4 - <&mut core[1b81ed6b3b69d0c3]::fmt::Formatter as serde[9162d223e4f5d80a]::ser::Serializer>::serialize_struct_variant
  37:     0x7ffbf6ab0ca5 - rustc_driver[5ae0ad532d132115]::pretty::print_after_hir_lowering
  38:     0x7ffbf6a549a0 - <&mut core[1b81ed6b3b69d0c3]::fmt::Formatter as serde[9162d223e4f5d80a]::ser::Serializer>::serialize_struct_variant
  39:     0x7ffbf6a2dd27 - <&mut core[1b81ed6b3b69d0c3]::fmt::Formatter as serde[9162d223e4f5d80a]::ser::Serializer>::serialize_struct_variant
  40:     0x7ffbf6a9aae6 - <rustc_metadata[f47eeeeabaa7db06]::rmeta::encoder::EncodeContext as rustc_serialize[ec78526cf068bb80]::serialize::Encoder>::emit_raw_bytes
  41:     0x7ffbf6a5d778 - <rustc_driver[5ae0ad532d132115]::args::Error as core[1b81ed6b3b69d0c3]::fmt::Debug>::fmt
  42:     0x7ffc1e6eedec - std::sys::windows::thread::Thread::new::h87bd3fa2cc7c7644
  43:     0x7ffc96367034 - BaseThreadInitThunk
  44:     0x7ffc97ba2651 - RtlUserThreadStart

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jun 1, 2022
b-naber

b-naber commented on Jun 2, 2022

@b-naber
Contributor

@rustbot claim

added a commit that references this issue on Jun 2, 2022
wesleywiser

wesleywiser commented on Jun 3, 2022

@wesleywiser
Member

I think this is only tangentially related to -Cinstrument-coverage in that using that flag enables -Csymbol-mangling-version=v0. The v0 mangling system doesn't currently implement support for floating point constants:

bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty(), ct);

The v0 mangling RFC describes how to define the floating point types:

https://github.com/rust-lang/rfcs/blob/9925276189646646beffbc4f84ca03b037ff7569/text/2603-rust-symbol-name-mangling-v0.md?plain=1#L695-L715

but does not define how to encode their values:

https://github.com/rust-lang/rfcs/blob/9925276189646646beffbc4f84ca03b037ff7569/text/2603-rust-symbol-name-mangling-v0.md?plain=1#L780-L783

So I think this will require design work and an amendment to that RFC to specify.

tmiasko

tmiasko commented on Jul 11, 2022

@tmiasko
Contributor

Floating point types are forbidden as const generic parameters. Since #98907 the appropriate error is emitted in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @wesleywiser@mikialex@tmiasko@rust-lang-glacier-bot@b-naber

      Issue actions

        ICE with adt_const_params and instrument-coverage · Issue #97625 · rust-lang/rust