Repository navigation
ICE with unsizing an extern type #79409
Copy link
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-extern_types`#![feature(extern_types)]``#![feature(extern_types)]`F-unsized_locals`#![feature(unsized_locals)]``#![feature(unsized_locals)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Description
Code
#![feature(extern_types)]
#![feature(unsized_locals)]
extern {
type Device;
}
unsafe fn make_device() -> Box<Device> {
Box::from_raw(0 as *mut _)
}
fn main() {
let d: Device = unsafe { *make_device() };
}Meta
rustc --version --verbose:
rustc 1.50.0-nightly (1c389ffef 2020-11-24)
Error output
thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `false`,
right: `true`', compiler/rustc_codegen_llvm/src/builder.rs:445:9
Backtrace
stack backtrace:
0: rust_begin_unwind
at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/core/src/panicking.rs:92:14
2: <rustc_codegen_llvm::builder::Builder as rustc_codegen_ssa::traits::builder::BuilderMethods>::load_operand
3: rustc_codegen_ssa::mir::operand::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_consume
4: rustc_codegen_ssa::mir::operand::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_operand
5: rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_block
6: rustc_codegen_ssa::mir::codegen_mir
7: rustc_codegen_ssa::base::codegen_instance
8: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
9: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
10: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
11: rustc_codegen_llvm::base::compile_codegen_unit
12: rustc_codegen_ssa::base::codegen_crate
13: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
14: rustc_interface::queries::Queries::ongoing_codegen
15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
16: rustc_span::with_source_map
17: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-extern_types`#![feature(extern_types)]``#![feature(extern_types)]`F-unsized_locals`#![feature(unsized_locals)]``#![feature(unsized_locals)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Activity
SNCPlay42 commentedon Nov 25, 2020
It seems clear to me that this shouldn't compile: there's no way to determine, even at run time, how many bytes of storage
dneeds (short of looking at the external code to see the size ofDevice, or calling some function in the compiled extern code to ask what the size ofDeviceis, neither of which can be done in general). So we just can't support an unsized local of an extern type.But this presents a pretty big problem: unsized locals of
?Sizedgeneric parameter types. This program can't be correct (and indeed it ICEs the same way as the original code), but which part of it is in error?It seems to me that these features can't coexist as they are currently -
extern_typesbreaksunsized_locals's fundamental assumption that at runtime we can determine the size of any type, even?Sizedones.I think this needs discussion from the lang team.
Enselic commentedon Aug 29, 2023
Triage: Still reproduces in Playground on current nightly, now at
compiler/rustc_codegen_llvm/src/builder.rs:491:9.matthiaskrgr commentedon Jan 9, 2024
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
19 remaining items
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Rollup merge of rust-lang#141811 - mejrs:bye_locals, r=compiler-errors
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=oli-obk
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk