Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice: cfi with repr(transparent): transform_ty: unexpected Alias(Projection, AliasTy` #111185

Closed
matthiaskrgr opened this issue May 4, 2023 · 0 comments · Fixed by #112182
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

rustc treereduce.out --edition=2021 -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Clto

#![crate_type = "lib"]

trait Mirror {
    type It: ?Sized;
}
impl<T: ?Sized> Mirror for T {
    type It = Self;
}

#[repr(transparent)]
pub struct StructWithProjection(<f32 as Mirror>::It);

pub extern "C" fn test_Projection() -> StructWithProjection {
    loop {}
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (6f8c0557e 2023-05-04)
binary: rustc
commit-hash: 6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c
commit-date: 2023-05-04
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output


Backtrace

warning: function `test_Projection` should have a snake case name
  --> treereduce.out:13:19
   |
13 | pub extern "C" fn test_Projection() -> StructWithProjection {
   |                   ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `test_projection`
   |
   = note: `#[warn(non_snake_case)]` on by default

error: internal compiler error: compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs:881:13: transform_ty: unexpected `Alias(Projection, AliasTy { substs: [f32], def_id: DefId(0:4 ~ treereduce[3c3c]::Mirror::It) })`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/compiler/rustc_errors/src/lib.rs:1643:9
stack backtrace:
   0:     0x7f3fee369441 - std::backtrace_rs::backtrace::libunwind::trace::ha1124e3c4b659eb5
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f3fee369441 - std::backtrace_rs::backtrace::trace_unsynchronized::h3a8d622ec81b6cb5
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3fee369441 - std::sys_common::backtrace::_print_fmt::h2128e938c7086b6e
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f3fee369441 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc50c3543d0b1b52f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f3fee3ca0df - core::fmt::rt::Argument::fmt::h84c36e9580f5b71f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/core/src/fmt/rt.rs:138:9
   5:     0x7f3fee3ca0df - core::fmt::write::h326e01f7a9aa5dd9
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f3fee35c4f1 - std::io::Write::write_fmt::h71f0f6281149b8c8
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/io/mod.rs:1712:15
   7:     0x7f3fee369255 - std::sys_common::backtrace::_print::h6b9c2111a065fb89
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f3fee369255 - std::sys_common::backtrace::print::hf8d0af7625f66057
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f3fee36bee7 - std::panicking::default_hook::{{closure}}::h630fe7740556559d
  10:     0x7f3fee36bcd4 - std::panicking::default_hook::h337047625b381696
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/panicking.rs:288:9
  11:     0x7f3ff1571715 - rustc_driver_impl[f38315262de66e12]::DEFAULT_HOOK::{closure#0}::{closure#0}
  12:     0x7f3fee36c607 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1ac669e77ecf459f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1999:9
  13:     0x7f3fee36c607 - std::panicking::rust_panic_with_hook::h22ef26cea64ec65c
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/panicking.rs:695:13
  14:     0x7f3ff1a39901 - std[2e06b57a958d7603]::panicking::begin_panic::<rustc_errors[5778b576bff5e43e]::ExplicitBug>::{closure#0}
  15:     0x7f3ff1a392a6 - std[2e06b57a958d7603]::sys_common::backtrace::__rust_end_short_backtrace::<std[2e06b57a958d7603]::panicking::begin_panic<rustc_errors[5778b576bff5e43e]::ExplicitBug>::{closure#0}, !>
  16:     0x7f3ff1a5fca6 - std[2e06b57a958d7603]::panicking::begin_panic::<rustc_errors[5778b576bff5e43e]::ExplicitBug>
  17:     0x7f3ff1a5d114 - <rustc_errors[5778b576bff5e43e]::HandlerInner>::bug::<alloc[3df6c3833cdafa3e]::string::String>
  18:     0x7f3ff1a5ce46 - <rustc_errors[5778b576bff5e43e]::Handler>::bug::<alloc[3df6c3833cdafa3e]::string::String>
  19:     0x7f3ff1ae52cc - rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt::<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}
  20:     0x7f3ff1ae4afa - rustc_middle[9b03ef73197c8750]::ty::context::tls::with_opt::<rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f3ff1ae4aca - rustc_middle[9b03ef73197c8750]::ty::context::tls::with_context_opt::<rustc_middle[9b03ef73197c8750]::ty::context::tls::with_opt<rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f3fefc50ccd - rustc_middle[9b03ef73197c8750]::util::bug::bug_fmt
  23:     0x7f3ff1fc9752 - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  24:     0x7f3ff1fc96fa - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  25:     0x7f3ff1fc9db1 - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::typeid_for_fnabi
  26:     0x7f3fefb7059f - <rustc_codegen_llvm[d78081c433bf4e31]::context::CodegenCx as rustc_codegen_ssa[7c934ba332e0ab85]::traits::declare::PreDefineMethods>::predefine_fn
  27:     0x7f3ff0a1a0dd - rustc_codegen_llvm[d78081c433bf4e31]::base::compile_codegen_unit::module_codegen
  28:     0x7f3ff0a18fb0 - rustc_codegen_llvm[d78081c433bf4e31]::base::compile_codegen_unit
  29:     0x7f3ff0c5c416 - rustc_codegen_ssa[7c934ba332e0ab85]::base::codegen_crate::<rustc_codegen_llvm[d78081c433bf4e31]::LlvmCodegenBackend>
  30:     0x7f3ff0c5bce2 - <rustc_codegen_llvm[d78081c433bf4e31]::LlvmCodegenBackend as rustc_codegen_ssa[7c934ba332e0ab85]::traits::backend::CodegenBackend>::codegen_crate
  31:     0x7f3ff07ff8e0 - rustc_interface[32f66f6c15b482f4]::passes::start_codegen
  32:     0x7f3ff07facc7 - <rustc_middle[9b03ef73197c8750]::ty::context::GlobalCtxt>::enter::<<rustc_interface[32f66f6c15b482f4]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<alloc[3df6c3833cdafa3e]::boxed::Box<dyn core[351080cb3919538e]::any::Any>, rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  33:     0x7f3ff07fa2a8 - <rustc_interface[32f66f6c15b482f4]::queries::Queries>::ongoing_codegen
  34:     0x7f3ff07f99e3 - <rustc_interface[32f66f6c15b482f4]::interface::Compiler>::enter::<rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}::{closure#2}, core[351080cb3919538e]::result::Result<core[351080cb3919538e]::option::Option<rustc_interface[32f66f6c15b482f4]::queries::Linker>, rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  35:     0x7f3ff07f714f - std[2e06b57a958d7603]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[32f66f6c15b482f4]::util::run_in_thread_pool_with_globals<rustc_interface[32f66f6c15b482f4]::interface::run_compiler<core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>, rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}>::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  36:     0x7f3ff0e58a1e - <<std[2e06b57a958d7603]::thread::Builder>::spawn_unchecked_<rustc_interface[32f66f6c15b482f4]::util::run_in_thread_pool_with_globals<rustc_interface[32f66f6c15b482f4]::interface::run_compiler<core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>, rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}>::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#1} as core[351080cb3919538e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f3fee376ad5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he4e640066a72afb4
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1985:9
  38:     0x7f3fee376ad5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6a43b4ec147b3dd9
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1985:9
  39:     0x7f3fee376ad5 - std::sys::unix::thread::Thread::new::thread_start::h8c269a865bc351fb
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7f3fee112bb5 - <unknown>
  41:     0x7f3fee194d90 - <unknown>
  42:                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: rustc 1.71.0-nightly (6f8c0557e 2023-05-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z sanitizer=cfi -Z sanitizer-cfi-normalize-integers -C lto

query stack during panic:
end of query stack
error: aborting due to previous error; 1 warning emitted

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 4, 2023
@matthiaskrgr matthiaskrgr added the PG-exploit-mitigations Project group: Exploit mitigations label May 13, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 2, 2023
…piler-errors

CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(Proj

Fixes rust-lang#111185 by normalizing ty::Alias before encoding.
@bors bors closed this as completed in faf31b5 Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant