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: TailCall terminator is not yet supported by rustc_codegen_ssa #127520

Closed
matthiaskrgr opened this issue Jul 9, 2024 · 6 comments
Closed
Labels
C-bug Category: This is a bug. F-explicit_tail_calls `#![feature(explicit_tail_calls)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jul 9, 2024

reduced:

#![feature(explicit_tail_calls)]

fn main() {
    become g(0);
}

fn g(_: i32) {}

original:

#![feature(explicit_tail_calls)]
#![allow(incomplete_features)]

fn main() {
    // FIXME(explicit_tail_calls):
    //   the error should point to `become g(x)`,
    //   but tail calls mess up the backtrace it seems like...
    f(0);
    //~^ error: Undefined Behavior: calling a function with argument of type i32 passing data of type u32
}

fn f(x: u32) {
    let g = unsafe { std::mem::transmute::<fn(i32), fn(u32)>(g) };
    become g(x);
}

fn g(_: i32) {}

Version information

rustc 1.81.0-nightly (a2d58197a 2024-07-09)
binary: rustc
commit-hash: a2d58197a766085856504328948c89a33a6a36e8
commit-date: 2024-07-09
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: the feature `explicit_tail_calls` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.tNpsz48Sq8cn/rustc_testrunner_tmpdir_reporting.cYSB4nfZwqUk/mvce.rs:1:12
  |
1 | #![feature(explicit_tail_calls)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #112788 <https://github.com/rust-lang/rust/issues/112788> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: internal compiler error: /rustc/a2d58197a766085856504328948c89a33a6a36e8/compiler/rustc_codegen_ssa/src/mir/block.rs:1394:17: `TailCall` terminator is not yet supported by `rustc_codegen_ssa`
 --> /tmp/icemaker_global_tempdir.tNpsz48Sq8cn/rustc_testrunner_tmpdir_reporting.cYSB4nfZwqUk/mvce.rs:9:5
  |
9 |     become g(x);
  |     ^^^^^^^^^^^

thread 'rustc' panicked at /rustc/a2d58197a766085856504328948c89a33a6a36e8/compiler/rustc_codegen_ssa/src/mir/block.rs:1394:17:
Box<dyn Any>
stack backtrace:
   0:     0x7d55c3d19635 - std::backtrace_rs::backtrace::libunwind::trace::he13237cce988f53a
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7d55c3d19635 - std::backtrace_rs::backtrace::trace_unsynchronized::ha201234a79e1b48c
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7d55c3d19635 - std::sys::backtrace::_print_fmt::hd9cfa658072ab2df
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/sys/backtrace.rs:68:5
   3:     0x7d55c3d19635 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2dad1e978c9e79ed
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/sys/backtrace.rs:44:22
   4:     0x7d55c3d68d1b - core::fmt::rt::Argument::fmt::h730e19369aa4f808
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/core/src/fmt/rt.rs:173:76
   5:     0x7d55c3d68d1b - core::fmt::write::hdfe1035cf0a4efa1
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/core/src/fmt/mod.rs:1182:21
   6:     0x7d55c3d0df6f - std::io::Write::write_fmt::h03dd478e1beb99ad
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/io/mod.rs:1835:15
   7:     0x7d55c3d1940e - std::sys::backtrace::_print::h57a2b1e60fc2c4b9
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/sys/backtrace.rs:47:5
   8:     0x7d55c3d1940e - std::sys::backtrace::print::h9505429ddc3ddaae
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/sys/backtrace.rs:34:9
   9:     0x7d55c3d1bd59 - std::panicking::default_hook::{{closure}}::hdda69c4ec7eb9df6
  10:     0x7d55c3d1bafc - std::panicking::default_hook::h86919ed8fb6d78eb
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/panicking.rs:292:9
  11:     0x7d55c026233a - std[17a9183c6e3c57f9]::panicking::update_hook::<alloc[96dff5c9794ac641]::boxed::Box<rustc_driver_impl[54b2714eb49b5e44]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7d55c3d1c67f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h48d0327b488509c8
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/alloc/src/boxed.rs:2078:9
  13:     0x7d55c3d1c67f - std::panicking::rust_panic_with_hook::h064be6ac2c876781
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/panicking.rs:804:13
  14:     0x7d55c029d291 - std[17a9183c6e3c57f9]::panicking::begin_panic::<rustc_errors[d6d035c9d1e266a6]::ExplicitBug>::{closure#0}
  15:     0x7d55c0290246 - std[17a9183c6e3c57f9]::sys::backtrace::__rust_end_short_backtrace::<std[17a9183c6e3c57f9]::panicking::begin_panic<rustc_errors[d6d035c9d1e266a6]::ExplicitBug>::{closure#0}, !>
  16:     0x7d55c028b576 - std[17a9183c6e3c57f9]::panicking::begin_panic::<rustc_errors[d6d035c9d1e266a6]::ExplicitBug>
  17:     0x7d55c02a64d1 - <rustc_errors[d6d035c9d1e266a6]::diagnostic::BugAbort as rustc_errors[d6d035c9d1e266a6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7d55c00abcfd - <rustc_errors[d6d035c9d1e266a6]::DiagCtxtHandle>::span_bug::<rustc_span[b622c74bbfdcda1]::span_encoding::Span, alloc[96dff5c9794ac641]::string::String>
  19:     0x7d55c00cd3d8 - rustc_middle[5daf59f269113cc0]::util::bug::opt_span_bug_fmt::<rustc_span[b622c74bbfdcda1]::span_encoding::Span>::{closure#0}
  20:     0x7d55c00cd49a - rustc_middle[5daf59f269113cc0]::ty::context::tls::with_opt::<rustc_middle[5daf59f269113cc0]::util::bug::opt_span_bug_fmt<rustc_span[b622c74bbfdcda1]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7d55c00be61b - rustc_middle[5daf59f269113cc0]::ty::context::tls::with_context_opt::<rustc_middle[5daf59f269113cc0]::ty::context::tls::with_opt<rustc_middle[5daf59f269113cc0]::util::bug::opt_span_bug_fmt<rustc_span[b622c74bbfdcda1]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7d55c00bddf7 - rustc_middle[5daf59f269113cc0]::util::bug::span_bug_fmt::<rustc_span[b622c74bbfdcda1]::span_encoding::Span>
  23:     0x7d55be6ed830 - <rustc_codegen_ssa[d135271512090c94]::mir::FunctionCx<rustc_codegen_llvm[b8ac9bda03fa3769]::builder::Builder>>::codegen_terminator
  24:     0x7d55c262aa23 - rustc_codegen_ssa[d135271512090c94]::mir::codegen_mir::<rustc_codegen_llvm[b8ac9bda03fa3769]::builder::Builder>
  25:     0x7d55c261349c - rustc_codegen_llvm[b8ac9bda03fa3769]::base::compile_codegen_unit::module_codegen
  26:     0x7d55c2610818 - <rustc_codegen_llvm[b8ac9bda03fa3769]::LlvmCodegenBackend as rustc_codegen_ssa[d135271512090c94]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  27:     0x7d55c27d8327 - <rustc_codegen_llvm[b8ac9bda03fa3769]::LlvmCodegenBackend as rustc_codegen_ssa[d135271512090c94]::traits::backend::CodegenBackend>::codegen_crate
  28:     0x7d55c28b109a - <rustc_interface[303575eb6bc5efad]::queries::Linker>::codegen_and_build_linker
  29:     0x7d55c25ec976 - rustc_interface[303575eb6bc5efad]::interface::run_compiler::<core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>, rustc_driver_impl[54b2714eb49b5e44]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7d55c25d2ac9 - std[17a9183c6e3c57f9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[303575eb6bc5efad]::util::run_in_thread_with_globals<rustc_interface[303575eb6bc5efad]::util::run_in_thread_pool_with_globals<rustc_interface[303575eb6bc5efad]::interface::run_compiler<core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>, rustc_driver_impl[54b2714eb49b5e44]::run_compiler::{closure#0}>::{closure#1}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>::{closure#0}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>
  31:     0x7d55c25d287a - <<std[17a9183c6e3c57f9]::thread::Builder>::spawn_unchecked_<rustc_interface[303575eb6bc5efad]::util::run_in_thread_with_globals<rustc_interface[303575eb6bc5efad]::util::run_in_thread_pool_with_globals<rustc_interface[303575eb6bc5efad]::interface::run_compiler<core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>, rustc_driver_impl[54b2714eb49b5e44]::run_compiler::{closure#0}>::{closure#1}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>::{closure#0}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f2873ee8fdb51630]::result::Result<(), rustc_span[b622c74bbfdcda1]::ErrorGuaranteed>>::{closure#2} as core[f2873ee8fdb51630]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7d55c3d264db - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e7f345ce8c283af
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/alloc/src/boxed.rs:2064:9
  33:     0x7d55c3d264db - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hace4a6e345e267d6
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/alloc/src/boxed.rs:2064:9
  34:     0x7d55c3d264db - std::sys::pal::unix::thread::Thread::new::thread_start::hebe8226876a7b7bb
                               at /rustc/a2d58197a766085856504328948c89a33a6a36e8/library/std/src/sys/pal/unix/thread.rs:108:17
  35:     0x7d55bcca6ded - <unknown>
  36:     0x7d55bcd2a0dc - <unknown>
  37:                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 make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (a2d58197a 2024-07-09) running on x86_64-unknown-linux-gnu

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


@rustbot label +F-explicit_tail_calls

@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 Jul 9, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-explicit_tail_calls `#![feature(explicit_tail_calls)]` labels Jul 9, 2024
@WaffleLapkin
Copy link
Member

warning: the feature `explicit_tail_calls` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.tNpsz48Sq8cn/rustc_testrunner_tmpdir_reporting.cYSB4nfZwqUk/mvce.rs:1:12
  |
1 | #![feature(explicit_tail_calls)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #112788 <https://github.com/rust-lang/rust/issues/112788> for more information
  = note: `#[warn(incomplete_features)]` on by default

@WaffleLapkin WaffleLapkin closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
@matthiaskrgr
Copy link
Member Author

?

@matthiaskrgr matthiaskrgr added the requires-incomplete-features This issue requires the use of incomplete features. label Jul 9, 2024
@matthiaskrgr matthiaskrgr reopened this Jul 9, 2024
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jul 9, 2024

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

@workingjubilee
Copy link
Member

"we would appreciate a bug report" is not a promise to never "wontfix" it.

@WaffleLapkin
Copy link
Member

@matthiaskrgr

warning: the feature explicit_tail_calls is incomplete and may not be safe to use and/or cause compiler crashes

The part about appreciating a bug report is generic ICE message, we don't ever change it, even in cases where bug reports are not useful.

Please don't fuzz incomplete features in general, and explicit tail calls in particular. This is not useful in any way.

@WaffleLapkin WaffleLapkin closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jul 10, 2024

The part about appreciating a bug report is generic ICE message, we don't ever change it, even in cases where bug reports are not useful.

This is incorrect, see:

if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
} else {
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 12, 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. F-explicit_tail_calls `#![feature(explicit_tail_calls)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. 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

5 participants