-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.
Description
#![feature(core_intrinsics)]
extern crate core;
use core::intrinsics;
fn write_reg<T: Copy>(reg: u32, val: T) {
unsafe { intrinsics::volatile_store(reg as *mut T, val); }
}
fn main() {
write_reg(0x10000000, ());
}
I was met with an internal compiler error:
error: internal compiler error: unexpected panic
I expected some kind of user-comprehensible error, instead.
Meta
Rust version: rustc 1.19.0-nightly (01951a61a 2017-05-20)
Associated Rust Playground: https://is.gd/ZHy4Av
Backtrace:
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /checkout/src/librustc_trans/intrinsic.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:355
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:365
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:549
5: std::panicking::begin_panic
at /checkout/src/libstd/panicking.rs:511
6: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:495
7: rust_begin_unwind
at /checkout/src/libstd/panicking.rs:471
8: core::panicking::panic_fmt
at /checkout/src/libcore/panicking.rs:69
9: core::panicking::panic_bounds_check
at /checkout/src/libcore/panicking.rs:56
10: rustc_trans::intrinsic::trans_intrinsic_call
11: rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_block
12: rustc_trans::mir::trans_mir
13: rustc_trans::trans_item::TransItem::define
14: rustc_trans::base::trans_crate
15: rustc_driver::driver::phase_4_translate_to_llvm
16: rustc_driver::driver::compile_input::{{closure}}
17: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
18: rustc_driver::driver::phase_3_run_analysis_passes
19: rustc_driver::driver::compile_input
20: rustc_driver::run_compiler
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]ICE when passing certain arrays to generic function[/-][+]ICE when using `copy_from_slice` on an array literal[/+][-]ICE when using `copy_from_slice` on an array literal[/-][+]ICE when passing `()` to a function generic over `Copy`[/+]kennytm commentedon May 22, 2017
The problem is use of ZST, not generics.
TimNN commentedon May 24, 2017
This can be reproduced without directly using the intrinsic as well:
Aaron1011 commentedon May 27, 2017
I'd like to work on this.
arielb1 commentedon May 27, 2017
@Aaron1011
I can try to mentor this (ping me on IRC)
The problem occurs when function calls are translated to LLVM - the match block here:
https://github.com/rust-lang/rust/blob/master/src/librustc_trans/mir/block.rs#L393
This is a part of trans code, which turns Rust MIR (mid-level IR, defined at https://github.com/rust-lang/rust/blob/master/src/librustc/mir/mod.rs) into LLVM IR (documented at http://llvm.org/docs/LangRef.html). It translates the typed, "unified-value-representation", ABI-unaware MIR into mostly-typeless and ABI-aware LLVM IR.
The problem is that in normal ABIs, zero-typed arguments are marked as
ignore
here: https://github.com/rust-lang/rust/blob/master/src/librustc_trans/abi.rs#L701, which leads totrans_argument
not pushing them into the argument array here: https://github.com/rust-lang/rust/blob/master/src/librustc_trans/mir/block.rs#L626.As a fix, you could either refactor intrinsics not to use the
trans_argument
path, or to change the ABI code to not mark ZSTs as ignore with therust-intrinsic
ABI. The latter should be just changing theif
to also require the ABI to not berust-intrinsic
.eminence commentedon Dec 6, 2017
Bug triage: The minimal ZST reproducer from TimNN now compiles without error on the current stable (1.22.1), beta, and nightly. The original reproducer (using core_intrinsics) now compiles without error on the current nightly (
rustc 1.23.0-nightly (e97ba8328 2017-11-25)
)Add tests to fixed issues.
Rollup merge of rust-lang#47344 - topecongiro:fixed-ices, r=alexcrichton
4 remaining items