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: unboxed closure but only with mir-opt-level=0 #114665

Open
matthiaskrgr opened this issue Aug 9, 2023 · 3 comments
Open

ICE: unboxed closure but only with mir-opt-level=0 #114665

matthiaskrgr opened this issue Aug 9, 2023 · 3 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-unboxed_closures `#![feature(unboxed_closures)]` 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

@matthiaskrgr
Copy link
Member

Code

from #66696
rustc -Zmir-opt-level=0 file.rs

#![feature(unboxed_closures)]
fn main() {
    unsafe { std::mem::transmute::<usize, extern "rust-call" fn()>(5); }
}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (f88a8b71c 2023-08-08)
binary: rustc
commit-hash: f88a8b71cebb730cbd5058c45ebcae1d4d9be377
commit-date: 2023-08-08
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_ty_utils/src/abi.rs:355:13: argument to function with "rust-call" ABI is not a tuple

thread 'rustc' panicked at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/compiler/rustc_errors/src/lib.rs:1635:9:
Box<dyn Any>
stack backtrace:
   0:     0x7fb75b0dc41c - std::backtrace_rs::backtrace::libunwind::trace::hca136959d52e6933
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb75b0dc41c - std::backtrace_rs::backtrace::trace_unsynchronized::h1c6a8e094542be1c
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb75b0dc41c - std::sys_common::backtrace::_print_fmt::h0da2398478023750
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fb75b0dc41c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b6a573864c0f846
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb75b14191c - core::fmt::rt::Argument::fmt::he6fd7e0d0105a739
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/core/src/fmt/rt.rs:138:9
   5:     0x7fb75b14191c - core::fmt::write::h94f577461195b051
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fb75b0cefce - std::io::Write::write_fmt::hd1a9413609baf17e
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/io/mod.rs:1714:15
   7:     0x7fb75b0dc204 - std::sys_common::backtrace::_print::h6209835ea4995823
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb75b0dc204 - std::sys_common::backtrace::print::he714f50554d615bf
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb75b0df2fa - std::panicking::panic_hook_with_disk_dump::{{closure}}::h3bcbb7ff457b5172
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/panicking.rs:278:22
  10:     0x7fb75b0defe7 - std::panicking::panic_hook_with_disk_dump::he69919c08bd7c189
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/panicking.rs:312:9
  11:     0x7fb759f41c99 - <rustc_driver_impl[a3b376697c1f9d40]::install_ice_hook::{closure#0} as core[5c8cf3808a1d57ad]::ops::function::FnOnce<(&core[5c8cf3808a1d57ad]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7fb75b0dfba0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha904a5fedd1a6164
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/alloc/src/boxed.rs:2021:9
  13:     0x7fb75b0dfba0 - std::panicking::rust_panic_with_hook::h2a611f1a2fc1b8fc
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/panicking.rs:733:13
  14:     0x7fb75a4e3891 - std[daf38f5e158042c3]::panicking::begin_panic::<rustc_errors[7d56c13f6856642f]::ExplicitBug>::{closure#0}
  15:     0x7fb75a4e3636 - std[daf38f5e158042c3]::sys_common::backtrace::__rust_end_short_backtrace::<std[daf38f5e158042c3]::panicking::begin_panic<rustc_errors[7d56c13f6856642f]::ExplicitBug>::{closure#0}, !>
  16:     0x7fb75a4e3526 - std[daf38f5e158042c3]::panicking::begin_panic::<rustc_errors[7d56c13f6856642f]::ExplicitBug>
  17:     0x7fb75a4291a4 - <rustc_errors[7d56c13f6856642f]::HandlerInner>::bug::<alloc[221a7a11f5e0e716]::string::String>
  18:     0x7fb75a429036 - <rustc_errors[7d56c13f6856642f]::Handler>::bug::<alloc[221a7a11f5e0e716]::string::String>
  19:     0x7fb75a4dd41c - rustc_middle[4e39534ad143988e]::util::bug::opt_span_bug_fmt::<rustc_span[fbb5fda749e896f2]::span_encoding::Span>::{closure#0}
  20:     0x7fb75a4dc1fa - rustc_middle[4e39534ad143988e]::ty::context::tls::with_opt::<rustc_middle[4e39534ad143988e]::util::bug::opt_span_bug_fmt<rustc_span[fbb5fda749e896f2]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fb75a4dc1c8 - rustc_middle[4e39534ad143988e]::ty::context::tls::with_context_opt::<rustc_middle[4e39534ad143988e]::ty::context::tls::with_opt<rustc_middle[4e39534ad143988e]::util::bug::opt_span_bug_fmt<rustc_span[fbb5fda749e896f2]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fb758de4340 - rustc_middle[4e39534ad143988e]::util::bug::bug_fmt
  23:     0x7fb75888db02 - rustc_ty_utils[2b480d80ea03f19d]::abi::fn_abi_new_uncached
  24:     0x7fb75993fe5e - rustc_ty_utils[2b480d80ea03f19d]::abi::fn_abi_of_fn_ptr
  25:     0x7fb75937515d - rustc_query_impl[e5a2310130a23b66]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e5a2310130a23b66]::query_impl::fn_abi_of_fn_ptr::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4e39534ad143988e]::query::erase::Erased<[u8; 16usize]>>
  26:     0x7fb75937511a - <rustc_query_impl[e5a2310130a23b66]::query_impl::fn_abi_of_fn_ptr::dynamic_query::{closure#2} as core[5c8cf3808a1d57ad]::ops::function::FnOnce<(rustc_middle[4e39534ad143988e]::ty::context::TyCtxt, rustc_middle[4e39534ad143988e]::ty::ParamEnvAnd<(rustc_middle[4e39534ad143988e]::ty::sty::Binder<rustc_middle[4e39534ad143988e]::ty::sty::FnSig>, &rustc_middle[4e39534ad143988e]::ty::list::List<rustc_middle[4e39534ad143988e]::ty::Ty>)>)>>::call_once
  27:     0x7fb7594f65ba - rustc_query_system[f19bd4f68b2513a8]::query::plumbing::try_execute_query::<rustc_query_impl[e5a2310130a23b66]::DynamicConfig<rustc_query_system[f19bd4f68b2513a8]::query::caches::DefaultCache<rustc_middle[4e39534ad143988e]::ty::ParamEnvAnd<(rustc_middle[4e39534ad143988e]::ty::sty::Binder<rustc_middle[4e39534ad143988e]::ty::sty::FnSig>, &rustc_middle[4e39534ad143988e]::ty::list::List<rustc_middle[4e39534ad143988e]::ty::Ty>)>, rustc_middle[4e39534ad143988e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[e5a2310130a23b66]::plumbing::QueryCtxt, false>
  28:     0x7fb7594f6287 - rustc_query_impl[e5a2310130a23b66]::query_impl::fn_abi_of_fn_ptr::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fb75826cc1f - <rustc_codegen_llvm[bf58ef99b94ec857]::context::CodegenCx as rustc_middle[4e39534ad143988e]::ty::layout::FnAbiOf>::fn_abi_of_fn_ptr
  30:     0x7fb758269899 - <rustc_target[5754b8683141b86c]::abi::TyAndLayout<rustc_middle[4e39534ad143988e]::ty::Ty> as rustc_codegen_llvm[bf58ef99b94ec857]::type_of::LayoutLlvmExt>::llvm_type
  31:     0x7fb758940adb - <rustc_codegen_ssa[845c4d9d94d655c1]::mir::FunctionCx<rustc_codegen_llvm[bf58ef99b94ec857]::builder::Builder>>::codegen_transmute_operand
  32:     0x7fb7589236ce - <rustc_codegen_ssa[845c4d9d94d655c1]::mir::FunctionCx<rustc_codegen_llvm[bf58ef99b94ec857]::builder::Builder>>::codegen_rvalue_operand
  33:     0x7fb7588f8161 - rustc_codegen_ssa[845c4d9d94d655c1]::mir::codegen_mir::<rustc_codegen_llvm[bf58ef99b94ec857]::builder::Builder>
  34:     0x7fb758d79e68 - rustc_codegen_llvm[bf58ef99b94ec857]::base::compile_codegen_unit::module_codegen
  35:     0x7fb758d76f60 - rustc_codegen_llvm[bf58ef99b94ec857]::base::compile_codegen_unit
  36:     0x7fb758d73b05 - rustc_codegen_ssa[845c4d9d94d655c1]::base::codegen_crate::<rustc_codegen_llvm[bf58ef99b94ec857]::LlvmCodegenBackend>
  37:     0x7fb758d73526 - <rustc_codegen_llvm[bf58ef99b94ec857]::LlvmCodegenBackend as rustc_codegen_ssa[845c4d9d94d655c1]::traits::backend::CodegenBackend>::codegen_crate
  38:     0x7fb7591fd982 - <rustc_session[5b68303f1d45cafc]::session::Session>::time::<alloc[221a7a11f5e0e716]::boxed::Box<dyn core[5c8cf3808a1d57ad]::any::Any>, rustc_interface[bbd54b40b3118f42]::passes::start_codegen::{closure#0}>
  39:     0x7fb7591fd4db - rustc_interface[bbd54b40b3118f42]::passes::start_codegen
  40:     0x7fb7591f70da - <rustc_middle[4e39534ad143988e]::ty::context::GlobalCtxt>::enter::<<rustc_interface[bbd54b40b3118f42]::queries::Queries>::ongoing_codegen::{closure#0}, core[5c8cf3808a1d57ad]::result::Result<alloc[221a7a11f5e0e716]::boxed::Box<dyn core[5c8cf3808a1d57ad]::any::Any>, rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>>
  41:     0x7fb7591f5f45 - rustc_span[fbb5fda749e896f2]::set_source_map::<core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>, rustc_interface[bbd54b40b3118f42]::interface::run_compiler<core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>, rustc_driver_impl[a3b376697c1f9d40]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  42:     0x7fb7591f03b0 - std[daf38f5e158042c3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bbd54b40b3118f42]::util::run_in_thread_pool_with_globals<rustc_interface[bbd54b40b3118f42]::interface::run_compiler<core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>, rustc_driver_impl[a3b376697c1f9d40]::run_compiler::{closure#1}>::{closure#0}, core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>>
  43:     0x7fb7597b76f5 - <<std[daf38f5e158042c3]::thread::Builder>::spawn_unchecked_<rustc_interface[bbd54b40b3118f42]::util::run_in_thread_pool_with_globals<rustc_interface[bbd54b40b3118f42]::interface::run_compiler<core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>, rustc_driver_impl[a3b376697c1f9d40]::run_compiler::{closure#1}>::{closure#0}, core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c8cf3808a1d57ad]::result::Result<(), rustc_span[fbb5fda749e896f2]::ErrorGuaranteed>>::{closure#1} as core[5c8cf3808a1d57ad]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7fb75b0ea225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he74562cf0068d98a
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/alloc/src/boxed.rs:2007:9
  45:     0x7fb75b0ea225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h499befea8267854a
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/alloc/src/boxed.rs:2007:9
  46:     0x7fb75b0ea225 - std::sys::unix::thread::Thread::new::thread_start::h94d7dff6e38d6249
                               at /rustc/f88a8b71cebb730cbd5058c45ebcae1d4d9be377/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7fb756c6444b - <unknown>
  48:     0x7fb756ce7e40 - <unknown>
  49:                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: please attach the file at `/home/matthias/vcs/github/glacier2/fixed/rustc-ice-2023-08-09T17:42:31.324359464Z-2419293.txt` to your bug report

note: compiler flags: -Z mir-opt-level=0

query stack during panic:
#0 [fn_abi_of_fn_ptr] computing call ABI of `extern "rust-call" fn()` function pointers
end of query stack
error: aborting due to previous error

@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. requires-nightly This issue requires a nightly compiler in some way. F-unboxed_closures `#![feature(unboxed_closures)]` labels Aug 9, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 9, 2023
@compiler-errors compiler-errors removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 9, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2020-05-27 🤔

commit[0] 2020-05-25: Auto merge of #72575 - Dylan-DPC:rollup-zo679hv, r=Dylan-DPC
commit[1] 2020-05-25: Auto merge of #72589 - Dylan-DPC:rollup-7l2a2bo, r=Dylan-DPC
commit[2] 2020-05-26: Auto merge of #71487 - rcoh:71471-shebang, r=petrochenkov
commit[3] 2020-05-26: Auto merge of #72093 - jonas-schievink:unmut, r=oli-obk
commit[4] 2020-05-26: Auto merge of #71900 - GuillaumeGomez:clean-up-rustdoc, r=ollie27,kinnison
commit[5] 2020-05-26: Auto merge of #71931 - alexcrichton:reproducible-macos, r=eddyb
ERROR: no CI builds available between f93bb2a and 5239f5c

@matthiaskrgr
Copy link
Member Author

maybe #72451 ?

@bjorn3
Copy link
Member

bjorn3 commented Aug 15, 2023

extern "rust-call" fn() is not a well-formed type. The last argument for extern "rust-call" needs to be a tuple. I don't think we actually check this well-formedness constraint inside typeck as we should though.

@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 19, 2024
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-unboxed_closures `#![feature(unboxed_closures)]` 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