Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
raphaelcohn opened this issue Mar 14, 2019 · 3 comments
Closed

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

raphaelcohn opened this issue Mar 14, 2019 · 3 comments
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@raphaelcohn
Copy link

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
	}
}
@jonas-schievink jonas-schievink added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. A-inline-assembly Area: Inline assembly (`asm!(…)`) labels Mar 14, 2019
@hellow554
Copy link
Contributor

Maybe related to #51130 ?

@raphaelcohn
Copy link
Author

Possibly.

@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Oct 25, 2019
@JohnTitor JohnTitor added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 22, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 29, 2020
@Amanieu
Copy link
Member

Amanieu commented May 22, 2020

This issue does not apply to the new asm! (RFC 2850) which doesn't support memory constraints.

The legacy llvm_asm! is deprecated and is no longer maintained.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants