rust-lang / rust

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

ICE: CFI: failed to normalize #114160

Closed matthiaskrgr closed 1 month ago

matthiaskrgr commented 1 year ago

Code

rustc -Zsanitizer=cfi -Clto -Zvalidate-mir file.rs

struct Cursor {}
struct TokenTree {}

impl Iterator for Cursor {
    type Item = TokenTree;

    fn next(&mut self) -> Option<TokenTree> {
        None
    }
}

fn tokenstream_probably_equal_for_proc_macro() {
    fn break_tokens(_tree: TokenTree) -> impl Iterator {
        let token_trees: Vec<TokenTree> = vec![];
        token_trees.into_iter()
    }

    let c1 = Cursor {};
    let c2 = Cursor {};

    let mut t1 = c1.flat_map(break_tokens);
    let mut t2 = c2.flat_map(break_tokens);

    for (_t1, _t2) in t1.by_ref().zip(t2.by_ref()) {}
}

fn main() {
    tokenstream_probably_equal_for_proc_macro();
}

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_middle/src/ty/normalize_erasing_regions.rs:195:90: Failed to normalize std::option::Option<(<&mut std::iter::FlatMap, fn(TokenTree) -> impl std::iter::Iterator {tokenstream_probably_equal_for_proc_macro::break_tokens}> as std::iter::Iterator>::Item, <&mut std::iter::FlatMap, fn(TokenTree) -> impl std::iter::Iterator {tokenstream_probably_equal_for_proc_macro::break_tokens}> as std::iter::Iterator>::Item)>, maybe try to call `try_normalize_erasing_regions` instead thread 'rustc' panicked at 'Box', /rustc/0be11523110a8354120068cd5c69434fdec2dc87/compiler/rustc_errors/src/lib.rs:1645:9 stack backtrace: 0: 0x7fe26c162fc1 - std::backtrace_rs::backtrace::libunwind::trace::h11251a01d1f7368f at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fe26c162fc1 - std::backtrace_rs::backtrace::trace_unsynchronized::h8c7e9c161dec6ceb at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fe26c162fc1 - std::sys_common::backtrace::_print_fmt::h3dbd85d6c7b23aee at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7fe26c162fc1 - ::fmt::h0d3e596e8094daf5 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7fe26c1c949c - core::fmt::rt::Argument::fmt::h4fcb9ccc4ae8b178 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/core/src/fmt/rt.rs:138:9 5: 0x7fe26c1c949c - core::fmt::write::hde6b07169611e983 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/core/src/fmt/mod.rs:1094:21 6: 0x7fe26c1557ae - std::io::Write::write_fmt::hadeda9f51824c419 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/io/mod.rs:1714:15 7: 0x7fe26c162dd5 - std::sys_common::backtrace::_print::h16e96fa77560cf6c at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7fe26c162dd5 - std::sys_common::backtrace::print::hd2b25c630669a41b at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7fe26c165e2a - std::panicking::panic_hook_with_disk_dump::{{closure}}::h820f75f8c35ebc61 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:278:22 10: 0x7fe26c165ac3 - std::panicking::panic_hook_with_disk_dump::h254fc8cd4ac07a17 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:312:9 11: 0x7fe26f383859 - >::call_once::{shim:vtable#0} 12: 0x7fe26c1666d0 - as core::ops::function::Fn>::call::h6b21a74b9087088a at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2021:9 13: 0x7fe26c1666d0 - std::panicking::rust_panic_with_hook::h88d69e7f62e6ab00 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/panicking.rs:733:13 14: 0x7fe26f904621 - std[f8657784229daa3e]::panicking::begin_panic::::{closure#0} 15: 0x7fe26f9028b6 - std[f8657784229daa3e]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7fe26f8bf676 - std[f8657784229daa3e]::panicking::begin_panic:: 17: 0x7fe26f95ebb4 - ::bug:: 18: 0x7fe26f95ea38 - ::bug:: 19: 0x7fe26f98264c - rustc_middle[9ff9a8da46dab689]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7fe26f98144a - rustc_middle[9ff9a8da46dab689]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7fe26f981418 - rustc_middle[9ff9a8da46dab689]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7fe26de3d7c0 - rustc_middle[9ff9a8da46dab689]::util::bug::bug_fmt 23: 0x7fe26d582736 - >::fold_ty 24: 0x7fe26dc53ba7 - <&rustc_middle[9ff9a8da46dab689]::ty::list::List as rustc_type_ir[bdd47b881fb85426]::fold::TypeFoldable>::try_fold_with:: 25: 0x7fe26dc55c35 - rustc_ty_utils[cae53f24ff15ba1]::abi::fn_abi_new_uncached 26: 0x7fe26dc52eaf - rustc_ty_utils[cae53f24ff15ba1]::abi::fn_abi_of_instance 27: 0x7fe26d41e19f - rustc_query_impl[9659d37ffb281dd2]::plumbing::__rust_begin_short_backtrace::> 28: 0x7fe26e17959e - rustc_query_system[f67fa4e91318ac5a]::query::plumbing::try_execute_query::)>, rustc_middle[9ff9a8da46dab689]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[9659d37ffb281dd2]::plumbing::QueryCtxt, false> 29: 0x7fe26e17918a - rustc_query_impl[9659d37ffb281dd2]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace 30: 0x7fe26fe37402 - rustc_symbol_mangling[db9110d89b8803cd]::typeid::typeid_itanium_cxx_abi::typeid_for_instance 31: 0x7fe26dbafd9c - ::predefine_fn 32: 0x7fe26e46f67c - rustc_codegen_llvm[9be676f5ea734376]::base::compile_codegen_unit::module_codegen 33: 0x7fe26e46d2d9 - rustc_codegen_llvm[9be676f5ea734376]::base::compile_codegen_unit 34: 0x7fe26e469ac4 - rustc_codegen_ssa[4f9ac761dca802d4]::base::codegen_crate:: 35: 0x7fe26e4694bb - ::codegen_crate 36: 0x7fe26e5ac5a2 - ::time::, rustc_interface[107315fc4480df53]::passes::start_codegen::{closure#0}> 37: 0x7fe26e5ac11b - rustc_interface[107315fc4480df53]::passes::start_codegen 38: 0x7fe26e5a6daa - ::enter::<::ongoing_codegen::{closure#0}, core[446b5c3084867e6e]::result::Result, rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>> 39: 0x7fe26e5a5de3 - ::enter::, rustc_span[ae27aa9cbbacfb85]::ErrorGuaranteed>> 40: 0x7fe26e59ee38 - 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>> 41: 0x7fe26e59e5be - <::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} 42: 0x7fe26c170dc5 - as core::ops::function::FnOnce>::call_once::h9a82d72b2d10ea03 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2007:9 43: 0x7fe26c170dc5 - as core::ops::function::FnOnce>::call_once::h9f222f89042b2a16 at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/alloc/src/boxed.rs:2007:9 44: 0x7fe26c170dc5 - std::sys::unix::thread::Thread::new::thread_start::ha2f5b7c44359c19a at /rustc/0be11523110a8354120068cd5c69434fdec2dc87/library/std/src/sys/unix/thread.rs:108:17 45: 0x7fe26bf0244b - 46: 0x7fe26bf85e40 - 47: 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 `/tmp/im/rustc-ice-2023-07-28T05:24:43.909419548Z-1954426.txt` to your bug report note: compiler flags: -Z sanitizer=cfi -C lto -Z mir-opt-level=0 -Z validate-mir query stack during panic: #0 [fn_abi_of_instance] computing call ABI of `, tokenstream_probably_equal_for_proc_macro::break_tokens>, &mut core::iter::adapters::flatten::FlatMap, tokenstream_probably_equal_for_proc_macro::break_tokens>> as core::iter::traits::iterator::Iterator>::next` end of query stack error: aborting due to previous error ```

rcvalle commented 1 year ago

@rustbot claim

Jules-Bertholet commented 5 months ago

@rustbot label A-sanitizers