rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.64k stars 12.49k forks source link

ICE: `used byval ABI for unsized layout` #124806

Open matthiaskrgr opened 4 months ago

matthiaskrgr commented 4 months ago

auto-reduced (treereduce-rust):

#![feature(abi_x86_interrupt)]
#![feature(unsized_fn_params)]
struct Test;

impl Test {
    pub extern "x86-interrupt" fn test(_a: str) {}
}

original:

struct Test;

impl Test {
    pub extern "x86-interrupt" fn test(_a: str) {

    }
}

Version information

rustc 1.80.0-nightly (25e3949aa 2024-05-06)
binary: rustc
commit-hash: 25e3949aa1b24b3f62a72c1f713830aa1d1efcd4
commit-date: 2024-05-06
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

Command: /home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(abi_x86_interrupt) -Zcrate-attr=feature(unsized_fn_params) -Clink-dead-code=true --crate-type=lib

Program output

``` warning: struct `Test` is never constructed --> /tmp/icemaker_global_tempdir.cFeBgsJNprxL/rustc_testrunner_tmpdir_reporting.zx6V8PkPVkHF/mvce.rs:1:8 | 1 | struct Test; | ^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated function `test` is never used --> /tmp/icemaker_global_tempdir.cFeBgsJNprxL/rustc_testrunner_tmpdir_reporting.zx6V8PkPVkHF/mvce.rs:4:35 | 3 | impl Test { | --------- associated function in this implementation 4 | pub extern "x86-interrupt" fn test(_a: str) {} | ^^^^ warning: `extern` fn uses type `str`, which is not FFI-safe --> /tmp/icemaker_global_tempdir.cFeBgsJNprxL/rustc_testrunner_tmpdir_reporting.zx6V8PkPVkHF/mvce.rs:4:44 | 4 | pub extern "x86-interrupt" fn test(_a: str) {} | ^^^ not FFI-safe | = help: consider using `*const u8` and a length instead = note: string slices have no C equivalent = note: `#[warn(improper_ctypes_definitions)]` on by default thread 'rustc' panicked at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/compiler/rustc_target/src/abi/call/mod.rs:662:9: used byval ABI for unsized layout stack backtrace: 0: 0x7520ddde0b35 - std::backtrace_rs::backtrace::libunwind::trace::h0237a9d37919b3ec at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x7520ddde0b35 - std::backtrace_rs::backtrace::trace_unsynchronized::h4c8f70ef1acfdb78 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7520ddde0b35 - std::sys_common::backtrace::_print_fmt::h5b738224e75de754 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7520ddde0b35 - ::fmt::hf9f7d71c4c529ad8 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7520dde2fcfb - core::fmt::rt::Argument::fmt::h03b0e1b7a27ddedf at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/core/src/fmt/rt.rs:165:63 5: 0x7520dde2fcfb - core::fmt::write::h248446ba3e345fa4 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/core/src/fmt/mod.rs:1157:21 6: 0x7520dddd58ff - std::io::Write::write_fmt::hac9e4b182ba2857c at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/io/mod.rs:1835:15 7: 0x7520ddde090e - std::sys_common::backtrace::_print::h54e0c4dd786df1a7 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7520ddde090e - std::sys_common::backtrace::print::h18113f9dcd919587 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7520ddde3279 - std::panicking::default_hook::{{closure}}::hebc9d09f9aaaef06 10: 0x7520ddde2fbd - std::panicking::default_hook::h2248d0b2ea6d5c7c at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/panicking.rs:298:9 11: 0x7520da6b6c00 - std[b086d9f741814aa7]::panicking::update_hook::>::{closure#0} 12: 0x7520ddde3976 - as core::ops::function::Fn>::call::hebac1653221b3ca4 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/alloc/src/boxed.rs:2036:9 13: 0x7520ddde3976 - std::panicking::rust_panic_with_hook::h2753b01180f345fa at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/panicking.rs:799:13 14: 0x7520ddde36eb - std::panicking::begin_panic_handler::{{closure}}::h59aac591d532bbdd at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/panicking.rs:656:13 15: 0x7520ddde0ff9 - std::sys_common::backtrace::__rust_end_short_backtrace::h80dab8854c18c59d at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys_common/backtrace.rs:171:18 16: 0x7520ddde3457 - rust_begin_unwind at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/panicking.rs:652:5 17: 0x7520dde2c2c3 - core::panicking::panic_fmt::hb8f3ed7d1c2faf0e at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/core/src/panicking.rs:72:14 18: 0x7520d935c141 - >::make_indirect_byval 19: 0x7520dc7255a2 - rustc_ty_utils[d072b78cb198a2f9]::abi::fn_abi_new_uncached 20: 0x7520dbc77faa - rustc_ty_utils[d072b78cb198a2f9]::abi::fn_abi_of_instance 21: 0x7520dbc76877 - rustc_query_impl[bc46c06982da3aa2]::plumbing::__rust_begin_short_backtrace::> 22: 0x7520dbc7480f - rustc_query_system[9914171e3cd4e2f]::query::plumbing::try_execute_query::)>, rustc_middle[dafa6f84b775271f]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[bc46c06982da3aa2]::plumbing::QueryCtxt, false> 23: 0x7520dbc74469 - rustc_query_impl[bc46c06982da3aa2]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace 24: 0x7520d8b44005 - ::predefine_fn 25: 0x7520dc6d2a13 - rustc_codegen_llvm[b4dd3527c9c5b42e]::base::compile_codegen_unit::module_codegen 26: 0x7520dc6ced16 - ::compile_codegen_unit 27: 0x7520dc927fdd - rustc_codegen_ssa[d63ee8fd2fa91707]::base::codegen_crate:: 28: 0x7520dc8214cc - ::codegen_crate 29: 0x7520dc820e5f - rustc_interface[5201622961cc16ec]::passes::start_codegen 30: 0x7520dc8204da - ::codegen_and_build_linker 31: 0x7520dc62522e - rustc_interface[5201622961cc16ec]::interface::run_compiler::, rustc_driver_impl[cd242fc3f331fee7]::run_compiler::{closure#0}>::{closure#1} 32: 0x7520dc60f989 - std[b086d9f741814aa7]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[cd242fc3f331fee7]::run_compiler::{closure#0}>::{closure#1}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>>::{closure#0}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>> 33: 0x7520dc60f736 - <::spawn_unchecked_, rustc_driver_impl[cd242fc3f331fee7]::run_compiler::{closure#0}>::{closure#1}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>>::{closure#0}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c1df39db662c9eb]::result::Result<(), rustc_span[6cb8761197abd2a5]::ErrorGuaranteed>>::{closure#2} as core[9c1df39db662c9eb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 34: 0x7520ddded7bb - as core::ops::function::FnOnce>::call_once::ha0c4bf88c896ff7b at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/alloc/src/boxed.rs:2022:9 35: 0x7520ddded7bb - as core::ops::function::FnOnce>::call_once::had08bec978f53e77 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/alloc/src/boxed.rs:2022:9 36: 0x7520ddded7bb - std::sys::pal::unix::thread::Thread::new::thread_start::haa511dd1bba6b653 at /rustc/25e3949aa1b24b3f62a72c1f713830aa1d1efcd4/library/std/src/sys/pal/unix/thread.rs:108:17 37: 0x7520ddb8c55a - 38: 0x7520ddc09a3c - 39: 0x0 - error: the compiler unexpectedly panicked. this is a bug. 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.80.0-nightly (25e3949aa 2024-05-06) running on x86_64-unknown-linux-gnu note: compiler flags: -Z crate-attr=feature(abi_x86_interrupt) -Z crate-attr=feature(unsized_fn_params) -C link-dead-code=true --crate-type lib -Z dump-mir-dir=dir query stack during panic: #0 [fn_abi_of_instance] computing call ABI of `::test` end of query stack warning: 3 warnings emitted ```

@rustbot label +F-abi_x86_interrupt +F-unsized_fn_params

JoverZhang commented 4 months ago

@rustbot claim

JoverZhang commented 4 months ago

I think I need more help with this.

I'm not sure if this is a ui bug or a missing feature. I may need a direction. :(

https://github.com/rust-lang/rust/blob/1fef1524f2717afb76832f1620ae54201f96523e/compiler/rustc_target/src/abi/call/mod.rs#L837-L843