Closed
Description
Was working on bug #61429 and tried to compile the program below. The inline assembly may be bogus: I make no guarantees of its correctness.
#![feature(asm)]
struct ThreadContext {
rsp: u64,
r15: u64,
}
fn gt_switch(new: *const ThreadContext) -> ! {
unsafe {
asm!("mov $1, $0" : "+r"("r15") : "*m"(&(*new).r15));
asm!("mov $1, $0" : "+r"("rsp") : "*m"(&(*new).rsp));
asm!("ret");
std::hint::unreachable_unchecked()
}
}
fn main() {
let ctx = ThreadContext{rsp: 0x80, r15: 0x88};
gt_switch(&ctx);
}
rustc
crashed with this output:
error: internal compiler error: src/librustc_codegen_ssa/mir/operand.rs:128: not immediate: OperandRef(Pair(([0 x i8]*: %10 = load [0 x i8]*, [0 x i8]** %9, align 8, !dbg !32, !nonnull !4), (i64: %12 = load i64, i64* %11, align 8, !dbg !32)) @ TyLayout { ty: &str, details: LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [Size { raw: 0 }, Size { raw: 8 }], memory_index: [0, 1] }, abi: ScalarPair(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }, Scalar { value: Int(I64, false), valid_range: 0..=18446744073709551615 }), align: AbiAndPrefAlign { abi: Align { pow2: 3 }, pref: Align { pow2: 3 } }, size: Size { raw: 16 } } })
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.37.0-nightly (929b48ec9 2019-06-21) running on x86_64-unknown-linux-gnu
Meta
rustc --version --verbose
:
rustc 1.37.0-nightly (929b48ec9 2019-06-21)
binary: rustc
commit-hash: 929b48ec98aaff2239257574b5897f419cec2647
commit-date: 2019-06-21
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0
(but also happened on a nightly from late May)