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

-Zrandomize-layout causes ICE when compiling syn (as part of a test) (with --target) #112065

Open
saethlin opened this issue May 29, 2023 · 3 comments
Labels
-Zrandomize-layout Unstable option: Randomize the layout of types. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

saethlin commented May 29, 2023

$ cargo download -x prettier-please
$ RUSTFLAGS="-Zrandomize-layout" cargo +nightly test --target=x86_64-unknown-linux-gnu --lib

rustc --version --verbose:

rustc 1.72.0-nightly (1c53407e8 2023-05-28)
binary: rustc
commit-hash: 1c53407e8c7cc922d718bde61ca34f47b6d2120f
commit-date: 2023-05-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

Error:

thread 'rustc' panicked at 'assertion failed: target_offset >= offset', compiler/rustc_codegen_llvm/src/type_of.rs:126:9
Backtrace

thread 'rustc' panicked at 'assertion failed: target_offset >= offset', compiler/rustc_codegen_llvm/src/type_of.rs:126:9
stack backtrace:
   0:     0x7f48a6969921 - std::backtrace_rs::backtrace::libunwind::trace::h2f87d9d5f9ce82d6
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f48a6969921 - std::backtrace_rs::backtrace::trace_unsynchronized::h43da12aa2b9d3c2f
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f48a6969921 - std::sys_common::backtrace::_print_fmt::hce2fdf626ac693ef
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f48a6969921 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2c0bda5382415c6f
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f48a69ca31f - core::fmt::rt::Argument::fmt::ha8dced8dec8d37aa
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/core/src/fmt/rt.rs:138:9
   5:     0x7f48a69ca31f - core::fmt::write::h77d649aab618411d
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f48a695cb11 - std::io::Write::write_fmt::h30551196154004c0
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/io/mod.rs:1713:15
   7:     0x7f48a6969735 - std::sys_common::backtrace::_print::h8e2356bc7d163cad
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f48a6969735 - std::sys_common::backtrace::print::ha0cb1b28bf8aa788
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f48a696c3f7 - std::panicking::default_hook::{{closure}}::h87bda075dafc0a5c
  10:     0x7f48a696c1e4 - std::panicking::default_hook::h68a37beb1a2d6a14
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/panicking.rs:288:9
  11:     0x7f48a9b1e64b - rustc_driver_impl[7659d0211759c851]::install_ice_hook::{closure#0}
  12:     0x7f48a696cb3d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he0663d30994fe530
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/alloc/src/boxed.rs:1999:9
  13:     0x7f48a696cb3d - std::panicking::rust_panic_with_hook::hd2f9c684d5205393
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/panicking.rs:709:13
  14:     0x7f48a696c891 - std::panicking::begin_panic_handler::{{closure}}::h1aa3874266ff3595
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/panicking.rs:595:13
  15:     0x7f48a6969d56 - std::sys_common::backtrace::__rust_end_short_backtrace::h7f2be3d4a5840a45
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f48a696c622 - rust_begin_unwind
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/panicking.rs:593:5
  17:     0x7f48a69c65a3 - core::panicking::panic_fmt::h38dc6fd12db28774
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/core/src/panicking.rs:67:14
  18:     0x7f48a69c6633 - core::panicking::panic::hc4f30bfaae186a6f
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/core/src/panicking.rs:117:5
  19:     0x7f48a7d20534 - rustc_codegen_llvm[454dee9a5a35a59a]::type_of::struct_llfields
  20:     0x7f48a7d1d777 - <rustc_target[a32af95a14d1468e]::abi::TyAndLayout<rustc_middle[9e72259b1eea478a]::ty::Ty> as rustc_codegen_llvm[454dee9a5a35a59a]::type_of::LayoutLlvmExt>::llvm_type
  21:     0x7f48a8581fac - <rustc_codegen_ssa[ab281534f5d7966c]::mir::FunctionCx<rustc_codegen_llvm[454dee9a5a35a59a]::builder::Builder>>::codegen_rvalue
  22:     0x7f48a8525834 - rustc_codegen_ssa[ab281534f5d7966c]::mir::codegen_mir::<rustc_codegen_llvm[454dee9a5a35a59a]::builder::Builder>
  23:     0x7f48a914b3eb - rustc_codegen_llvm[454dee9a5a35a59a]::base::compile_codegen_unit::module_codegen
  24:     0x7f48a9148909 - <rustc_codegen_llvm[454dee9a5a35a59a]::LlvmCodegenBackend as rustc_codegen_ssa[ab281534f5d7966c]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  25:     0x7f48a91462b7 - rustc_codegen_ssa[ab281534f5d7966c]::base::codegen_crate::<rustc_codegen_llvm[454dee9a5a35a59a]::LlvmCodegenBackend>
  26:     0x7f48a9145bbb - <rustc_codegen_llvm[454dee9a5a35a59a]::LlvmCodegenBackend as rustc_codegen_ssa[ab281534f5d7966c]::traits::backend::CodegenBackend>::codegen_crate
  27:     0x7f48a8d95621 - rustc_interface[45420231614740cd]::passes::start_codegen
  28:     0x7f48a8d9232d - <rustc_middle[9e72259b1eea478a]::ty::context::GlobalCtxt>::enter::<<rustc_interface[45420231614740cd]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[7efe0b4e56e81f9a]::result::Result<alloc[463a1543fa81c36a]::boxed::Box<dyn core[7efe0b4e56e81f9a]::any::Any>, rustc_span[2bf001af0057410c]::ErrorGuaranteed>>
  29:     0x7f48a8d912ad - <rustc_interface[45420231614740cd]::queries::Queries>::ongoing_codegen
  30:     0x7f48a8d908c9 - <rustc_interface[45420231614740cd]::interface::Compiler>::enter::<rustc_driver_impl[7659d0211759c851]::run_compiler::{closure#1}::{closure#2}, core[7efe0b4e56e81f9a]::result::Result<core[7efe0b4e56e81f9a]::option::Option<rustc_interface[45420231614740cd]::queries::Linker>, rustc_span[2bf001af0057410c]::ErrorGuaranteed>>
  31:     0x7f48a8d8e093 - std[1f5a572b0fe1d489]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[45420231614740cd]::util::run_in_thread_pool_with_globals<rustc_interface[45420231614740cd]::interface::run_compiler<core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>, rustc_driver_impl[7659d0211759c851]::run_compiler::{closure#1}>::{closure#0}, core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>>
  32:     0x7f48a93ba1f5 - <<std[1f5a572b0fe1d489]::thread::Builder>::spawn_unchecked_<rustc_interface[45420231614740cd]::util::run_in_thread_pool_with_globals<rustc_interface[45420231614740cd]::interface::run_compiler<core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>, rustc_driver_impl[7659d0211759c851]::run_compiler::{closure#1}>::{closure#0}, core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7efe0b4e56e81f9a]::result::Result<(), rustc_span[2bf001af0057410c]::ErrorGuaranteed>>::{closure#1} as core[7efe0b4e56e81f9a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f48a6977065 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3b74af01aa4409e3
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/alloc/src/boxed.rs:1985:9
  34:     0x7f48a6977065 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6fd53215ad4052a6
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/alloc/src/boxed.rs:1985:9
  35:     0x7f48a6977065 - std::sys::unix::thread::Thread::new::thread_start::h8df08f1507529c34
                               at /rustc/1c53407e8c7cc922d718bde61ca34f47b6d2120f/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f48a671144b - <unknown>
  37:     0x7f48a6794e40 - <unknown>
  38:                0x0 - <unknown>

@saethlin saethlin added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels May 29, 2023
@saethlin saethlin changed the title -Zrandomize-layout causes ICE when compiling syn with --target -Zrandomize-layout causes ICE when compiling syn (as part of a test) (with --target) May 29, 2023
@saethlin saethlin added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 29, 2023
@jyn514 jyn514 added the requires-nightly This issue requires a nightly compiler in some way. label Jun 1, 2023
@jyn514
Copy link
Member

jyn514 commented Jun 1, 2023

I take it the RUSTDOCFLAGS here are not actually relevant, since this is crashing in LLVM? So something like RUSTFLAGS="-Zrandomize-layout" cargo +nightly test --target=x86_64-unknown-linux-gnu -j1 --lib would be a more minimal reproduction?

@saethlin
Copy link
Member Author

saethlin commented Jun 1, 2023

Yes. Updated the issue description.

@Noratrieb Noratrieb added the -Zrandomize-layout Unstable option: Randomize the layout of types. label Jun 6, 2023
@trevyn
Copy link
Contributor

trevyn commented Jun 10, 2023

Related / dupe of #101646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zrandomize-layout Unstable option: Randomize the layout of types. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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