Closed
Description
When trying to compile the code below in a file asm.rs
, the Rust compiler segfaults (Segmentation Fault 11).
Example command line:-
rustc --edition=2018 asm.rs
(The presence of the --edition
tag seems irrelevant).
When asking for LLVM IR output, a segfault does not occur, eg rustc --emit llvm-ir -o asm.ir -v --edition=2018 asm.rs
.
The segfault also does not happen if the call to read_after_raising_any_exceptions()
is removed from main. It's possible my assembler is mis-formed, but that's not completely germane - the compiler should not segfault.
Version details from rustc -V
: rustc 1.35.0-nightly (719b0d984 2019-03-13)
OS: Mac OS 10.14.2 , running on a Mac Pro trashcan.
Rust code:-
#![feature(asm)]
fn main()
{
println!("Hello, world! {}", read_after_raising_any_exceptions());
}
#[inline(never)]
pub fn read_after_raising_any_exceptions() -> u16
{
unsafe
{
// See <https://github.com/HJLebbink/asm-dude/wiki/FSTCW_FNSTCW>.
let mut control_word: u16;
asm!
(
"fstcw $0"
:
// Output constraints.
"=m"(control_word)
:
// Input constraints.
:
// Clobbers.
:
// Options.
"volatile"
);
control_word
}
}
Metadata
Metadata
Assignees
Labels
Area: Inline assembly (`asm!(…)`)Category: This is a bug.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.