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: encode_region: unexpected ReEarlyBound(0, 'a) #111515

Closed
matthiaskrgr opened this issue May 12, 2023 · 1 comment · Fixed by #111851
Closed

ice: cfi: encode_region: unexpected ReEarlyBound(0, 'a) #111515

matthiaskrgr opened this issue May 12, 2023 · 1 comment · Fixed by #111851
Assignees
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

matthiaskrgr commented May 12, 2023

Code

rustc -Clto -Zsanitizer=cfi

pub trait MyTrait<'a> {
    type Output: 'a;
    fn gimme_value(&self) -> Self::Output;
}

pub struct MyStruct;

impl<'a> MyTrait<'a> for MyStruct {
    type Output = &'a usize;
    fn gimme_value(&self) -> Self::Output {
        unimplemented!()
    }
}

fn meow<T, F>(t: T, f: F)
where
    T: for<'any> MyTrait<'any>,
    F: for<'any2> Fn(<T as MyTrait<'any2>>::Output),
{
    let v = t.gimme_value();
    f(v);
}

fn main() {
    let struc = MyStruct;
    meow(struc, |foo| {})
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (077fc26f0 2023-05-12)
binary: rustc
commit-hash: 077fc26f0acfa54e9c580534616c17ffc279a9d4
commit-date: 2023-05-12
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs:285:13: encode_region: unexpected `ReEarlyBound(0, 'a)`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/compiler/rustc_errors/src/lib.rs:1650:9
stack backtrace:
   0:     0x7f746ff6a051 - std::backtrace_rs::backtrace::libunwind::trace::h3078c38bcf244cb0
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f746ff6a051 - std::backtrace_rs::backtrace::trace_unsynchronized::hae8fc14cdc8e4133
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f746ff6a051 - std::sys_common::backtrace::_print_fmt::hd18feb1e248cc700
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f746ff6a051 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0778d4788d776d0c
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f746ffca4af - core::fmt::rt::Argument::fmt::hfc4761188bd54631
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/core/src/fmt/rt.rs:138:9
   5:     0x7f746ffca4af - core::fmt::write::h79a7fdd9d194cc0d
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f746ff5d351 - std::io::Write::write_fmt::hf2bf8061d31c573e
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/io/mod.rs:1712:15
   7:     0x7f746ff69e65 - std::sys_common::backtrace::_print::hc8cc601132b2e52e
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f746ff69e65 - std::sys_common::backtrace::print::hd81a33670e423952
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f746ff6cae7 - std::panicking::default_hook::{{closure}}::h87364cf24ac04124
  10:     0x7f746ff6c8d4 - std::panicking::default_hook::h5b78b38c2a54b17a
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/panicking.rs:288:9
  11:     0x7f74731e8d1b - <rustc_driver_impl[13bf0d04f0b67ce9]::install_ice_hook::{closure#0} as core[9035cf7f5955cd74]::ops::function::FnOnce<(&core[9035cf7f5955cd74]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f746ff6d207 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hdc5f2153a7f41863
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/alloc/src/boxed.rs:1999:9
  13:     0x7f746ff6d207 - std::panicking::rust_panic_with_hook::h045d197919c3e8ba
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/panicking.rs:695:13
  14:     0x7f74736d8181 - std[b0554e33ca57edeb]::panicking::begin_panic::<rustc_errors[26f4fb3d98328957]::ExplicitBug>::{closure#0}
  15:     0x7f74736d5d06 - std[b0554e33ca57edeb]::sys_common::backtrace::__rust_end_short_backtrace::<std[b0554e33ca57edeb]::panicking::begin_panic<rustc_errors[26f4fb3d98328957]::ExplicitBug>::{closure#0}, !>
  16:     0x7f74736d59a6 - std[b0554e33ca57edeb]::panicking::begin_panic::<rustc_errors[26f4fb3d98328957]::ExplicitBug>
  17:     0x7f74736d0954 - <rustc_errors[26f4fb3d98328957]::HandlerInner>::bug::<alloc[b30310a06b34fd3]::string::String>
  18:     0x7f74736d0686 - <rustc_errors[26f4fb3d98328957]::Handler>::bug::<alloc[b30310a06b34fd3]::string::String>
  19:     0x7f747375a48c - rustc_middle[c66c2d2ac5a96442]::util::bug::opt_span_bug_fmt::<rustc_span[8db14cdbe7f466b8]::span_encoding::Span>::{closure#0}
  20:     0x7f747375a2ca - rustc_middle[c66c2d2ac5a96442]::ty::context::tls::with_opt::<rustc_middle[c66c2d2ac5a96442]::util::bug::opt_span_bug_fmt<rustc_span[8db14cdbe7f466b8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f747375a29a - rustc_middle[c66c2d2ac5a96442]::ty::context::tls::with_context_opt::<rustc_middle[c66c2d2ac5a96442]::ty::context::tls::with_opt<rustc_middle[c66c2d2ac5a96442]::util::bug::opt_span_bug_fmt<rustc_span[8db14cdbe7f466b8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f747142973d - rustc_middle[c66c2d2ac5a96442]::util::bug::bug_fmt
  23:     0x7f7473c519d9 - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::encode_region
  24:     0x7f7473c51ad8 - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::encode_substs
  25:     0x7f7473c51543 - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::encode_predicates
  26:     0x7f7473c52bfb - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::encode_ty
  27:     0x7f7473c52f8e - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::encode_ty
  28:     0x7f7473c556c4 - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::typeid_for_fnabi
  29:     0x7f7473c54f8a - rustc_symbol_mangling[f4730ed954a99ba6]::typeid::typeid_itanium_cxx_abi::typeid_for_instance
  30:     0x7f74715a733a - <rustc_codegen_llvm[c5a88784cad09a28]::context::CodegenCx as rustc_codegen_ssa[1d9595b98f3b7f2]::traits::declare::PreDefineMethods>::predefine_fn
  31:     0x7f7472656d91 - rustc_codegen_llvm[c5a88784cad09a28]::base::compile_codegen_unit::module_codegen
  32:     0x7f7472655d28 - rustc_codegen_llvm[c5a88784cad09a28]::base::compile_codegen_unit
  33:     0x7f74728adf3f - rustc_codegen_ssa[1d9595b98f3b7f2]::base::codegen_crate::<rustc_codegen_llvm[c5a88784cad09a28]::LlvmCodegenBackend>
  34:     0x7f74728ad7d0 - <rustc_codegen_llvm[c5a88784cad09a28]::LlvmCodegenBackend as rustc_codegen_ssa[1d9595b98f3b7f2]::traits::backend::CodegenBackend>::codegen_crate
  35:     0x7f74723ea750 - rustc_interface[813041c30d6fe35a]::passes::start_codegen
  36:     0x7f74723e6297 - <rustc_middle[c66c2d2ac5a96442]::ty::context::GlobalCtxt>::enter::<<rustc_interface[813041c30d6fe35a]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[9035cf7f5955cd74]::result::Result<alloc[b30310a06b34fd3]::boxed::Box<dyn core[9035cf7f5955cd74]::any::Any>, rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>
  37:     0x7f74723e5a0d - <rustc_interface[813041c30d6fe35a]::queries::Queries>::ongoing_codegen
  38:     0x7f74723e4ea3 - <rustc_interface[813041c30d6fe35a]::interface::Compiler>::enter::<rustc_driver_impl[13bf0d04f0b67ce9]::run_compiler::{closure#1}::{closure#2}, core[9035cf7f5955cd74]::result::Result<core[9035cf7f5955cd74]::option::Option<rustc_interface[813041c30d6fe35a]::queries::Linker>, rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>
  39:     0x7f74723e250b - std[b0554e33ca57edeb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[813041c30d6fe35a]::util::run_in_thread_pool_with_globals<rustc_interface[813041c30d6fe35a]::interface::run_compiler<core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>, rustc_driver_impl[13bf0d04f0b67ce9]::run_compiler::{closure#1}>::{closure#0}, core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>
  40:     0x7f74723e1c75 - <<std[b0554e33ca57edeb]::thread::Builder>::spawn_unchecked_<rustc_interface[813041c30d6fe35a]::util::run_in_thread_pool_with_globals<rustc_interface[813041c30d6fe35a]::interface::run_compiler<core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>, rustc_driver_impl[13bf0d04f0b67ce9]::run_compiler::{closure#1}>::{closure#0}, core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9035cf7f5955cd74]::result::Result<(), rustc_span[8db14cdbe7f466b8]::ErrorGuaranteed>>::{closure#1} as core[9035cf7f5955cd74]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f746ff776b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h45f6a2020dca9236
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/alloc/src/boxed.rs:1985:9
  42:     0x7f746ff776b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8428b00e1b18042
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/alloc/src/boxed.rs:1985:9
  43:     0x7f746ff776b5 - std::sys::unix::thread::Thread::new::thread_start::h99203a4e418970a3
                               at /rustc/077fc26f0acfa54e9c580534616c17ffc279a9d4/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f746fd15bb5 - <unknown>
  45:     0x7f746fd97d90 - <unknown>
  46:                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 (077fc26f0 2023-05-12) running on x86_64-unknown-linux-gnu

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

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. PG-exploit-mitigations Project group: Exploit mitigations labels May 12, 2023
@rcvalle
Copy link
Member

rcvalle commented May 22, 2023

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 23, 2023
CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)

Fixes rust-lang#111515 and complements rust-lang#106547 by adding support for encoding early bound regions and also excluding projections when transforming trait objects' traits into their identities before emitting type checks.
@bors bors closed this as completed in 9bbdfea May 23, 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.

2 participants