Skip to content

ICE (ish): Segfault with the following code #59184

Closed
@raphaelcohn

Description

@raphaelcohn

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

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions