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

Compilation of rkyv (lib) is failing after upgrade to rust 1.71 #113781

Open
pushkar85 opened this issue Jul 17, 2023 · 6 comments
Open

Compilation of rkyv (lib) is failing after upgrade to rust 1.71 #113781

pushkar85 opened this issue Jul 17, 2023 · 6 comments
Labels
C-bug Category: This is a bug. 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.

Comments

@pushkar85
Copy link

pushkar85 commented Jul 17, 2023

error: internal compiler error: no errors encountered even though delay_span_bug issued

error: internal compiler error: broken MIR in Item(DefId(0:1705 ~ rkyv[d260]::std_impl::{impl#47}::deserialize)) (after phase change to runtime-optimized) at bb0[22]:
Field projection PlaceRef { local: _1, projection: [Deref, Field(0, RelPtr<[<T as Archive>::Archived]>)] }.1 specified type u32, but actual type is <[<T as Archive>::Archived] as ArchivePointee>::ArchivedMetadata
--> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.6.7/src/core_impl/mod.rs:489:9

<code>

Meta

rustc --version --verbose:

rustc 1.71.0 (8ede3aae2 2023-07-12) running on x86_64-unknown-linux-gnu

Error output

error: internal compiler error: no errors encountered even though delay_span_bug issued
error: internal compiler error: broken MIR in Item(DefId(0:1705 ~ rkyv[14fb]::std_impl::{impl#47}::deserialize)) (after phase change to runtime-optimized) at bb0[27]:
Field projection (*_19).1 specified type u32, but actual type is <[<T as Archive>::Archived] as ArchivePointee>::ArchivedMetadata
--> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.6.7/src/lib.rs:765:77
|
765 | ptr_meta::from_raw_parts(self.raw_ptr.as_ptr(), T::pointer_metadata(&self.metadata))
| ^^^^^^^^^^^^^^
|
= note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:354:30
0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
2: <rustc_const_eval::transform::validate::TypeChecker>::fail::alloc::string::String
3: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_place
4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
5: rustc_mir_transform::optimized_mir
6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
7: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
9: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
10: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
11: rustc_metadata::rmeta::encoder::encode_metadata_impl
12: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
13: rustc_metadata::rmeta::encoder::encode_metadata
14: rustc_metadata::fs::encode_and_write_metadata
15: rustc_interface::passes::start_codegen
16: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box, rustc_span::ErrorGuaranteed>>
17: <rustc_interface::queries::Queries>::ongoing_codegen
18: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
19: std::sys_common::backtrace::_rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
20: <std::thread::Builder::spawn_unchecked
<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/alloc/src/boxed.rs:1985:9
22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/alloc/src/boxed.rs:1985:9
23: std::sys::unix::thread::Thread::new::thread_start
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys/unix/thread.rs:108:17
24: start_thread
25: __clone

error: internal compiler error: broken MIR in Item(DefId(0:1705 ~ rkyv[14fb]::std_impl::{impl#47}::deserialize)) (after phase change to runtime-optimized) at bb3[29]:
Field projection (*_37).1 specified type u32, but actual type is <[<T as Archive>::Archived] as ArchivePointee>::ArchivedMetadata
--> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.6.7/src/lib.rs:765:77
|
765 | ptr_meta::from_raw_parts(self.raw_ptr.as_ptr(), T::pointer_metadata(&self.metadata))
| ^^^^^^^^^^^^^^
|
= note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:354:30
0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
2: <rustc_const_eval::transform::validate::TypeChecker>::fail::alloc::string::String
3: <rustc_const_eval::transform::validate::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_place
4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
5: rustc_mir_transform::optimized_mir
6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
7: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
9: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
10: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
11: rustc_metadata::rmeta::encoder::encode_metadata_impl
12: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
13: rustc_metadata::rmeta::encoder::encode_metadata
14: rustc_metadata::fs::encode_and_write_metadata
15: rustc_interface::passes::start_codegen
16: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box, rustc_span::ErrorGuaranteed>>
17: <rustc_interface::queries::Queries>::ongoing_codegen
18: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
19: std::sys_common::backtrace::_rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
20: <std::thread::Builder::spawn_unchecked
<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/alloc/src/boxed.rs:1985:9
22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/alloc/src/boxed.rs:1985:9
23: std::sys::unix::thread::Thread::new::thread_start
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys/unix/thread.rs:108:17
24: start_thread
25: __clone

<output>
Backtrace

<backtrace>
``note: rustc 1.73.0-nightly (0e8e857b1 2023-07-16) running on x86_64-unknown-linux-gnu`


</p>
</details>
@pushkar85 pushkar85 added C-bug Category: This is a bug. 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. labels Jul 17, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 17, 2023
@lukas-code
Copy link
Member

duplicate of #112332

@pushkar85
Copy link
Author

@lukas-code is there any work around , currently its completely broken

@lukas-code
Copy link
Member

The bug seems to be fixed in rkyv 0.7, so if you can upgrade that would probably be the best solution.

Otherwise, if you're stuck with rkyv 0.6, you can hack around this by disabling the buggy optimization pass by setting these environment variables:

RUSTC_BOOTSTRAP=1 RUSTFLAGS=-Zmir-enable-passes=-Inline

(Note that this enables unstable options on the stable compiler and isn't really supported.)

@pushkar85
Copy link
Author

Thanks a lot @lukas-code , for now it has worked

@pushkar85
Copy link
Author

pushkar85 commented Jul 18, 2023

@cjgillot by when we can expect this patch to be included in rust 1.71

@pushkar85
Copy link
Author

pushkar85 commented Jul 19, 2023

The bug seems to be fixed in rkyv 0.7, so if you can upgrade that would probably be the best solution.

Otherwise, if you're stuck with rkyv 0.6, you can hack around this by disabling the buggy optimization pass by setting these environment variables:

RUSTC_BOOTSTRAP=1 RUSTFLAGS=-Zmir-enable-passes=-Inline

(Note that this enables unstable options on the stable compiler and isn't really supported.)

@lukas-code This workaround does not work , when any optimisation level is set .

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 21, 2023
…-errors

Substitute types before checking inlining compatibility.

Addresses rust-lang#112332 and rust-lang#113781

I don't have a minimal test, but I this seems to remove the ICE locally.

This whole pre-inlining validation mirrors the "real" MIR validation pass to verify that inlined MIR will still pass validation.
The debuginfo loop is added because MIR validation check projections in debuginfo.
Likewise, MIR validation only checks `is_subtype`, so there is no reason for a stronger check.

The types were not being substituted in `check_equal`, so we were not bailing out of inlining if the substituted MIR callee body would not pass validation.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jul 22, 2023
Substitute types before checking inlining compatibility.

Addresses rust-lang/rust#112332 and rust-lang/rust#113781

I don't have a minimal test, but I this seems to remove the ICE locally.

This whole pre-inlining validation mirrors the "real" MIR validation pass to verify that inlined MIR will still pass validation.
The debuginfo loop is added because MIR validation check projections in debuginfo.
Likewise, MIR validation only checks `is_subtype`, so there is no reason for a stronger check.

The types were not being substituted in `check_equal`, so we were not bailing out of inlining if the substituted MIR callee body would not pass validation.
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants