rust-lang / rust

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

ICE when compiling read_fonts crate with -Zsanitizer=cfi #128484

Closed 1c3t3a closed 1 month ago

1c3t3a commented 1 month ago

Code

Compiling the read_fonts crate (code) with RUSTFLAGS="-Clinker-plugin-lto -Zsanitizer=cfi" yields this error. I will try to lower down the code to a minimal reproducible example next week.

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (28a58f2fa 2024-07-31)
binary: rustc
commit-hash: 28a58f2fa7f0c46b8fab8237c02471a915924fe5
commit-date: 2024-07-31
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

<output>
Backtrace

``` RUST_BACKTRACE=full RUSTFLAGS="-Clinker-plugin-lto -Zsanitizer=cfi" cargo b -Zbuild-std -Zbuild-std-features --release --target x86_64-unknown-linux-gnu Compiling read-fonts v0.19.3 error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:90: Failed to normalize std::option::Option<(Alias(Projection, AliasTy { args: [std::iter::Chain>, Closure(DefId(0:1241 ~ read_fonts[4d05]::tables::layout::{impl#6}::iter::{closure#0}), ['{erased}, i16, Binder { value: extern "RustCall" fn((&'{erased} types::BigEndian,)) -> types::GlyphId, bound_vars: [] }, ()])>>>, std::iter::Flatten, std::iter::Map, FnDef(DefId(13:68 ~ font_types[0196]::glyph_id::{impl#0}::new), [])>, FnDef(DefId(0:1251 ~ read_fonts[4d05]::tables::layout::{impl#9}::iter), [])>>>>], def_id: DefId(2:8499 ~ core[d45d]::iter::traits::iterator::Iterator::Item), .. }), Alias(Projection, AliasTy { args: [std::iter::FromFn, types::Offset16, i16, Binder { value: extern "RustCall" fn(()) -> std::option::Option, read::ReadError>>>, bound_vars: [] }, (std::slice::Iter<'{erased}, types::BigEndian>>, font_data::FontData<'{erased}>, ())])>], def_id: DefId(2:8499 ~ core[d45d]::iter::traits::iterator::Iterator::Item), .. }))>, maybe try to call `try_normalize_erasing_regions` instead thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:90: Box stack backtrace: 0: 0x7ff86949754d - std::backtrace_rs::backtrace::libunwind::trace::h32241ecce7cc97b4 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x7ff86949754d - std::backtrace_rs::backtrace::trace_unsynchronized::he88bad54ee1027a8 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7ff86949754d - std::sys::backtrace::_print_fmt::h1a79c79abdff1de3 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/sys/backtrace.rs:66:9 3: 0x7ff86949754d - ::fmt::h4ba39a43d3e87adf at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/sys/backtrace.rs:39:26 4: 0x7ff8694e803b - core::fmt::rt::Argument::fmt::h6ad1535845790bc6 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/core/src/fmt/rt.rs:173:76 5: 0x7ff8694e803b - core::fmt::write::h948fa78229aa764e at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/core/src/fmt/mod.rs:1178:21 6: 0x7ff86948ba93 - std::io::Write::write_fmt::h60b4ed4b4cde96a3 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/io/mod.rs:1823:15 7: 0x7ff869499d42 - std::sys::backtrace::BacktraceLock::print::h5d733821ad3e76e5 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/sys/backtrace.rs:42:9 8: 0x7ff869499d42 - std::panicking::default_hook::{{closure}}::h326e80fe334527f5 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/panicking.rs:266:22 9: 0x7ff8694999ae - std::panicking::default_hook::h154dcec67b5cc2b3 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/panicking.rs:293:9 10: 0x7ff865abeef7 - std[6735b9bece8a6c64]::panicking::update_hook::>::{closure#0} 11: 0x7ff86949a732 - as core::ops::function::Fn>::call::h46ade2009b590b71 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/alloc/src/boxed.rs:2162:9 12: 0x7ff86949a732 - std::panicking::rust_panic_with_hook::haa0d1f76c5d6487e at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/panicking.rs:805:13 13: 0x7ff865af95e1 - std[6735b9bece8a6c64]::panicking::begin_panic::::{closure#0} 14: 0x7ff865aec486 - std[6735b9bece8a6c64]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 15: 0x7ff865aec436 - std[6735b9bece8a6c64]::panicking::begin_panic:: 16: 0x7ff865b02d01 - ::emit_producing_guarantee 17: 0x7ff8660d9074 - rustc_middle[7c03d9d3aaa26afb]::util::bug::opt_span_bug_fmt::::{closure#0} 18: 0x7ff8660be10a - rustc_middle[7c03d9d3aaa26afb]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 19: 0x7ff8660bdf8b - rustc_middle[7c03d9d3aaa26afb]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 20: 0x7ff863e8ce10 - rustc_middle[7c03d9d3aaa26afb]::util::bug::bug_fmt 21: 0x7ff86758e246 - >::fold_ty 22: 0x7ff86758d818 - as rustc_type_ir[d459e222c9f6e896]::fold::TypeFoldable>::try_fold_with:: 23: 0x7ff8677c1ba2 - rustc_ty_utils[cb5e61cfc0450708]::abi::fn_abi_new_uncached 24: 0x7ff8677bb121 - rustc_ty_utils[cb5e61cfc0450708]::abi::fn_abi_of_instance 25: 0x7ff8677b9b79 - rustc_query_impl[bf72133feb0f109a]::plumbing::__rust_begin_short_backtrace::> 26: 0x7ff8677b7b40 - rustc_query_system[c0479f94767de6d]::query::plumbing::try_execute_query::)>, rustc_middle[7c03d9d3aaa26afb]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[bf72133feb0f109a]::plumbing::QueryCtxt, false> 27: 0x7ff8677b778c - rustc_query_impl[bf72133feb0f109a]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace 28: 0x7ff86659d3a6 - rustc_sanitizers[41cc9708b15e165d]::cfi::typeid::itanium_cxx_abi::typeid_for_instance 29: 0x7ff8642fa5a4 - ::predefine_fn 30: 0x7ff867e9fda1 - rustc_codegen_llvm[6693dbe16cf67684]::base::compile_codegen_unit::module_codegen 31: 0x7ff867e9d082 - ::compile_codegen_unit 32: 0x7ff868083b66 - ::codegen_crate 33: 0x7ff8680b4158 - ::codegen_and_build_linker 34: 0x7ff867ed7d3b - rustc_interface[1300cdbf8ee6dff9]::interface::run_compiler::, rustc_driver_impl[5e3d74da74d89118]::run_compiler::{closure#0}>::{closure#1} 35: 0x7ff867e0c809 - std[6735b9bece8a6c64]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[5e3d74da74d89118]::run_compiler::{closure#0}>::{closure#1}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>>::{closure#0}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>> 36: 0x7ff867e0c5b2 - <::spawn_unchecked_, rustc_driver_impl[5e3d74da74d89118]::run_compiler::{closure#0}>::{closure#1}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>>::{closure#0}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[53251afa801eb14e]::result::Result<(), rustc_span[c29b4e18ee0a3f38]::ErrorGuaranteed>>::{closure#1} as core[53251afa801eb14e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 37: 0x7ff8694a455b - as core::ops::function::FnOnce>::call_once::h7501bf06aeb0baa1 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/alloc/src/boxed.rs:2148:9 38: 0x7ff8694a455b - as core::ops::function::FnOnce>::call_once::h822e7161a8507b21 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/alloc/src/boxed.rs:2148:9 39: 0x7ff8694a455b - std::sys::pal::unix::thread::Thread::new::thread_start::hd2564588fac3af04 at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library/std/src/sys/pal/unix/thread.rs:105:17 40: 0x7ff8624a539c - start_thread at ./nptl/pthread_create.c:444:8 41: 0x7ff862526608 - __GI___clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 42: 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 make sure that you have updated to the latest nightly note: please attach the file at `/usr/local/google/home/bkersting/.cargo/registry/src/index.crates.io-6f17d22bba15001f/read-fonts-0.19.3/rustc-ice-2024-08-01T09_45_29-517103.txt` to your bug report note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C strip=debuginfo -Z unstable-options -C linker-plugin-lto -Z sanitizer=cfi note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [fn_abi_of_instance] computing call ABI of `>, {closure@/usr/local/google/home/bkersting/.cargo/registry/src/index.crates.io-6f17d22bba15001f/read-fonts-0.19.3/src/tables/layout.rs:151:75: 151:78}>>>, core::iter::adapters::flatten::Flatten, core::iter::adapters::map::Map, font_types::glyph_id::GlyphId::new>, tables::layout::::iter>>>>, core::iter::sources::from_fn::FromFn<{closure@/usr/local/google/home/bkersting/.cargo/registry/src/index.crates.io-6f17d22bba15001f/read-fonts-0.19.3/src/offset_array.rs:143:28: 143:35}>> as core::iter::traits::iterator::Iterator>::next` end of query stack error: could not compile `read-fonts` (lib) ```

matthiaskrgr commented 1 month ago

this is probably a duplicate of https://github.com/rust-lang/rust/issues/114160

1c3t3a commented 1 month ago

Thanks @matthiaskrgr, it very much looks like it!

rcvalle commented 1 month ago

This was fixed in #128580.