Repository navigation
Closed
Description
auto-reduced (treereduce-rust):
#![feature(thin_box)]
use std::boxed::ThinBox;
use std::error::Error;
use std::fmt;
fn main() {
let expected = "Foo error!";
let a: ThinBox<dyn Error> = ThinBox::new_unsize(Foo(expected));
}
#[derive(Debug)]
struct Foo(&'static str);
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl Error for Foo {}
original:
#![feature(thin_box)]
// run-pass
use std::boxed::ThinBox;
use std::error::Error;
use std::ops::Deref;
use std::fmt;
fn main() {
let expected = "Foo error!";
let a: ThinBox<dyn Error> = ThinBox::new_unsize(Foo(expected));
let a = a.deref();
let msg = a.to_string();
assert_eq!(expected, msg);
}
#[derive(Debug)]
#[repr(align(1024))]
struct Foo(&'static str);
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl Error for Foo {}Version information
rustc 1.79.0-nightly (290d79241 2024-04-22)
binary: rustc
commit-hash: 290d792411566c94273e5d1a980a1ab91f1d950b
commit-date: 2024-04-22
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift
Program output
warning: unused variable: `a`
--> /tmp/icemaker_global_tempdir.gikjMqxOJjk8/rustc_testrunner_tmpdir_reporting.WOGOOImz49M8/mvce.rs:10:9
|
10 | let a: ThinBox<dyn Error> = ThinBox::new_unsize(Foo(expected));
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
= note: `#[warn(unused_variables)]` on by default
error: internal compiler error: src/value_and_place.rs:109:18: RawPtr operands CValue(ByVal(v3), TyAndLayout { ty: *mut (), layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 0..=18446744073709551615 }), fields: Primitive, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } }) CValue(ByRef(Pointer { base: Stack(ss1), offset: Offset32(0) }, None), TyAndLayout { ty: DynMetadata<dyn std::error::Error>, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes)], memory_index: [0, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } })
thread 'rustc' panicked at src/value_and_place.rs:109:18:
Box<dyn Any>
stack backtrace:
0: 0x7a9b144ac935 - std::backtrace_rs::backtrace::libunwind::trace::h26e1fa40e8cb8736
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x7a9b144ac935 - std::backtrace_rs::backtrace::trace_unsynchronized::h859af531c2f619a1
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7a9b144ac935 - std::sys_common::backtrace::_print_fmt::h770ada6f33df9a23
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7a9b144ac935 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1202620471ff2013
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7a9b144fba6b - core::fmt::rt::Argument::fmt::h1d7f69a8f0bb037c
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/core/src/fmt/rt.rs:165:63
5: 0x7a9b144fba6b - core::fmt::write::h2cfd50c1c61a678b
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/core/src/fmt/mod.rs:1157:21
6: 0x7a9b144a14bf - std::io::Write::write_fmt::h68244818dfe9446a
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/io/mod.rs:1832:15
7: 0x7a9b144ac70e - std::sys_common::backtrace::_print::hb0df927864ffa3c4
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7a9b144ac70e - std::sys_common::backtrace::print::hb29ea7496634044b
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7a9b144af079 - std::panicking::default_hook::{{closure}}::hcfcc8ff96a30a9c7
10: 0x7a9b144aedbd - std::panicking::default_hook::h8bb790ee0d607409
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/panicking.rs:298:9
11: 0x7a9b10e3227c - std[37c8ccdab8a3c0d8]::panicking::update_hook::<alloc[34ed19a5ff888b12]::boxed::Box<rustc_driver_impl[480b09937bfb0708]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7a9b144af776 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h11842aeeeb09579f
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/alloc/src/boxed.rs:2036:9
13: 0x7a9b144af776 - std::panicking::rust_panic_with_hook::h2039ccc53629d416
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/panicking.rs:799:13
14: 0x7a9b10e62584 - std[37c8ccdab8a3c0d8]::panicking::begin_panic::<rustc_errors[6444c462ca5918aa]::ExplicitBug>::{closure#0}
15: 0x7a9b10e5ef36 - std[37c8ccdab8a3c0d8]::sys_common::backtrace::__rust_end_short_backtrace::<std[37c8ccdab8a3c0d8]::panicking::begin_panic<rustc_errors[6444c462ca5918aa]::ExplicitBug>::{closure#0}, !>
16: 0x7a9b10e5a506 - std[37c8ccdab8a3c0d8]::panicking::begin_panic::<rustc_errors[6444c462ca5918aa]::ExplicitBug>
17: 0x7a9b10e6b801 - <rustc_errors[6444c462ca5918aa]::diagnostic::BugAbort as rustc_errors[6444c462ca5918aa]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7a9b1131155c - rustc_middle[d30f97e255128713]::util::bug::opt_span_bug_fmt::<rustc_span[128fa906eb8a1c67]::span_encoding::Span>::{closure#0}
19: 0x7a9b112f982a - rustc_middle[d30f97e255128713]::ty::context::tls::with_opt::<rustc_middle[d30f97e255128713]::util::bug::opt_span_bug_fmt<rustc_span[128fa906eb8a1c67]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x7a9b112f96cb - rustc_middle[d30f97e255128713]::ty::context::tls::with_context_opt::<rustc_middle[d30f97e255128713]::ty::context::tls::with_opt<rustc_middle[d30f97e255128713]::util::bug::opt_span_bug_fmt<rustc_span[128fa906eb8a1c67]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x7a9b0f68fe70 - rustc_middle[d30f97e255128713]::util::bug::bug_fmt
22: 0x7a9b03e14bc9 - rustc_codegen_cranelift[f872669b1689024d]::base::codegen_fn_body
23: 0x7a9b03e2a1bd - rustc_codegen_cranelift[f872669b1689024d]::driver::aot::module_codegen::{closure#0}
24: 0x7a9b03e26477 - rustc_codegen_cranelift[f872669b1689024d]::driver::aot::module_codegen
25: 0x7a9b03e33779 - rustc_codegen_cranelift[f872669b1689024d]::driver::aot::run_aot
26: 0x7a9b03e60f21 - <rustc_codegen_cranelift[f872669b1689024d]::CraneliftCodegenBackend as rustc_codegen_ssa[db212267bf182275]::traits::backend::CodegenBackend>::codegen_crate
27: 0x7a9b130a945d - rustc_interface[ffee9ea60ef965c3]::passes::start_codegen
28: 0x7a9b130a8ad8 - <rustc_interface[ffee9ea60ef965c3]::queries::Queries>::codegen_and_build_linker
29: 0x7a9b12dea7f6 - rustc_interface[ffee9ea60ef965c3]::interface::run_compiler::<core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>, rustc_driver_impl[480b09937bfb0708]::run_compiler::{closure#0}>::{closure#1}
30: 0x7a9b12dd8627 - std[37c8ccdab8a3c0d8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ffee9ea60ef965c3]::util::run_in_thread_with_globals<rustc_interface[ffee9ea60ef965c3]::util::run_in_thread_pool_with_globals<rustc_interface[ffee9ea60ef965c3]::interface::run_compiler<core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>, rustc_driver_impl[480b09937bfb0708]::run_compiler::{closure#0}>::{closure#1}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>::{closure#0}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>
31: 0x7a9b12dd83ea - <<std[37c8ccdab8a3c0d8]::thread::Builder>::spawn_unchecked_<rustc_interface[ffee9ea60ef965c3]::util::run_in_thread_with_globals<rustc_interface[ffee9ea60ef965c3]::util::run_in_thread_pool_with_globals<rustc_interface[ffee9ea60ef965c3]::interface::run_compiler<core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>, rustc_driver_impl[480b09937bfb0708]::run_compiler::{closure#0}>::{closure#1}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>::{closure#0}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d851a872a27282f9]::result::Result<(), rustc_span[128fa906eb8a1c67]::ErrorGuaranteed>>::{closure#2} as core[d851a872a27282f9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
32: 0x7a9b144b960b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8fcfbedcc7bc1020
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/alloc/src/boxed.rs:2022:9
33: 0x7a9b144b960b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb725f441e1474916
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/alloc/src/boxed.rs:2022:9
34: 0x7a9b144b960b - std::sys::pal::unix::thread::Thread::new::thread_start::h34c8a550ac2bc24c
at /rustc/290d792411566c94273e5d1a980a1ab91f1d950b/library/std/src/sys/pal/unix/thread.rs:108:17
35: 0x7a9b0dca955a - <unknown>
36: 0x7a9b0dd26a3c - <unknown>
37: 0x0 - <unknown>
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: please make sure that you have updated to the latest nightly
note: rustc 1.79.0-nightly (290d79241 2024-04-22) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z codegen-backend=cranelift -Z dump-mir-dir=dir
query stack during panic:
end of query stack
error: aborting due to 1 previous error; 1 warning emitted
@rustbot label +F-thin_box
Metadata
Metadata
Assignees
Labels
No labels
Activity
rustbot commentedon Apr 22, 2024
bjorn3 commentedon Apr 22, 2024
rust-lang/rust#123840 incorrectly assumed that scalar
CValue's are always represented asCValueInner::ByValwhile they can also be represented asCValueInner::ByRef. Unlike cg_ssa, cg_clif doesn't eagerly convert to the "canonical" form. Should be fixed in d0c5141.bjorn3 commentedon Apr 22, 2024
Will sync the fix to the rust repo after the next cranelift update is done later today.
bjorn3 commentedon May 3, 2024
Fixed with the latest sync.