rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.23k stars 12.7k forks source link

ICE: CFI: `encode_const: unexpected type '[[usize; 4]; 4]'` #114158

Open matthiaskrgr opened 1 year ago

matthiaskrgr commented 1 year ago

Code

rustc treereduce.out -Zsanitizer=cfi --crate-type lib -Clto

#![feature(adt_const_params)]

mod lib {
    const N_ISLANDS: usize = 4;
    const N_BRIDGES: usize = 7;
    const BRIDGES: [(usize, usize); 7] = [(0, 1), (0, 1), (0, 2), (0, 3), (0, 3), (1, 2), (2, 3)];

    pub type Matrix = [[usize; N_ISLANDS]; N_ISLANDS];

    const EMPTY_MATRIX: Matrix = [[0; N_ISLANDS]; N_ISLANDS];

    const fn to_matrix(bridges: [(usize, usize); N_BRIDGES]) -> Matrix {
        let matrix = EMPTY_MATRIX;

        matrix
    }

    const BRIDGE_MATRIX: [[usize; N_ISLANDS]; N_ISLANDS] = to_matrix(BRIDGES);

    pub struct Walk<const CURRENT: usize, const REMAINING: Matrix> {
        _p: (),
    }

    impl Walk<0, BRIDGE_MATRIX> {
        pub const fn new() -> Self {
            Self { _p: () }
        }
    }

    pub struct Trophy {
        _p: (),
    }
}

pub use lib::{Trophy, Walk};

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (0be115231 2023-07-27)
binary: rustc
commit-hash: 0be11523110a8354120068cd5c69434fdec2dc87
commit-date: 2023-07-27
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

<output>
Backtrace

``` error: internal compiler error: compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs:137:21: encode_const: unexpected type `[[usize; 4]; 4]` thread 'rustc' panicked at 'Box', /rustc/0be11523110a8354120068cd5c69434fdec2dc87/compiler/rustc_errors/src/lib.rs:1645:9 stack backtrace: 0: 0x7fe839d61fc1 - std::backtrace_rs::backtrace::libunwind::trace::h11251a01d1f7368f at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fe839d61fc1 - std::backtrace_rs::backtrace::trace_unsynchronized::h8c7e9c161dec6ceb at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fe839d61fc1 - std::sys_common::backtrace::_print_fmt::h3dbd85d6c7b23aee at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7fe839d61fc1 - ::fmt::h0d3e596e8094daf5 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7fe839dc849c - core::fmt::rt::Argument::fmt::h4fcb9ccc4ae8b178 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/core/src/fmt/rt.rs:138:9 5: 0x7fe839dc849c - core::fmt::write::hde6b07169611e983 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/core/src/fmt/mod.rs:1094:21 6: 0x7fe839d547ae - std::io::Write::write_fmt::hadeda9f51824c419 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/io/mod.rs:1714:15 7: 0x7fe839d61dd5 - std::sys_common::backtrace::_print::h16e96fa77560cf6c at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7fe839d61dd5 - std::sys_common::backtrace::print::hd2b25c630669a41b at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7fe839d64e2a - std::panicking::panic_hook_with_disk_dump::{{closure}}::h820f75f8c35ebc61 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:278:22 10: 0x7fe839d64ac3 - std::panicking::panic_hook_with_disk_dump::h254fc8cd4ac07a17 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:312:9 11: 0x7fe838b83859 - >::call_once::{shim:vtable#0} 12: 0x7fe839d656d0 - as core::ops::function::Fn>::call::h6b21a74b9087088a at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2021:9 13: 0x7fe839d656d0 - std::panicking::rust_panic_with_hook::h88d69e7f62e6ab00 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:733:13 14: 0x7fe839104621 - std[f8657784229daa3e]::panicking::begin_panic::::{closure#0} 15: 0x7fe8391028b6 - std[f8657784229daa3e]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7fe8390bf676 - std[f8657784229daa3e]::panicking::begin_panic:: 17: 0x7fe83915ebb4 - ::bug:: 18: 0x7fe83915ea38 - ::bug:: 19: 0x7fe83918264c - rustc_middle[9ff9a8da46dab689]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7fe83918144a - rustc_middle[9ff9a8da46dab689]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7fe839181418 - rustc_middle[9ff9a8da46dab689]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7fe83763d7c0 - rustc_middle[9ff9a8da46dab689]::util::bug::bug_fmt 23: 0x7fe8396338e6 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::encode_const 24: 0x7fe8396341f0 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::encode_args 25: 0x7fe839635ef6 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::encode_ty 26: 0x7fe839637ed6 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::typeid_for_fnabi 27: 0x7fe839637557 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::typeid_for_instance 28: 0x7fe8373afd9c - ::predefine_fn 29: 0x7fe837c6f67c - rustc_codegen_llvm[9be676f5ea734376]::base::compile_codegen_unit::module_codegen 30: 0x7fe837c6d2d9 - rustc_codegen_llvm[9be676f5ea734376]::base::compile_codegen_unit 31: 0x7fe837c69ac4 - rustc_codegen_ssa[4f9ac761dca802d4]::base::codegen_crate:: 32: 0x7fe837c694bb - ::codegen_crate 33: 0x7fe837dac5a2 - ::time::, rustc_interface[107315fc4480df53]::passes::start_codegen::{closure#0}> 34: 0x7fe837dac11b - rustc_interface[107315fc4480df53]::passes::start_codegen 35: 0x7fe837da6daa - ::enter::<::ongoing_codegen::{closure#0}, core[446b5c3084867e6e]::result::Result, rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>> 36: 0x7fe837da5de3 - ::enter::, rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>> 37: 0x7fe837d9ee38 - std[f8657784229daa3e]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[23d24208d96aabf1]::run_compiler::{closure#1}>::{closure#0}, core[446b5c3084867e6e]::result::Result<(), rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[446b5c3084867e6e]::result::Result<(), rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>> 38: 0x7fe837d9e5be - <::spawn_unchecked_, rustc_driver_impl[23d24208d96aabf1]::run_compiler::{closure#1}>::{closure#0}, core[446b5c3084867e6e]::result::Result<(), rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[446b5c3084867e6e]::result::Result<(), rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>>::{closure#1} as core[446b5c3084867e6e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 39: 0x7fe839d6fdc5 - as core::ops::function::FnOnce>::call_once::h9a82d72b2d10ea03 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2007:9 40: 0x7fe839d6fdc5 - as core::ops::function::FnOnce>::call_once::h9f222f89042b2a16 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2007:9 41: 0x7fe839d6fdc5 - std::sys::unix::thread::Thread::new::thread_start::ha2f5b7c44359c19a at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys/unix/thread.rs:108:17 42: 0x7fe83589344b - 43: 0x7fe835916e40 - 44: 0x0 - 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 attach the file at `/home/matthias/vcs/github/rust_bisect/rustc-ice-2023-07-28T05:14:57.200620104Z-1831474.txt` to your bug report note: compiler flags: -Z sanitizer=cfi --crate-type lib -C lto query stack during panic: end of query stack error: aborting due to previous error; 2 warnings emitted ```

rcvalle commented 1 year ago

@rustbot claim

Jules-Bertholet commented 7 months ago

@rustbot label A-sanitizers