Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Segfault when using an ymm register as an out parameter in an asm! block. #74658

Closed
in-the-mood-for-mov opened this issue Jul 22, 2020 · 0 comments · Fixed by #75014
Closed
Labels
C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) 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

@in-the-mood-for-mov
Copy link

Code

The following code segfaults when compiled (rustc asm-avx.rs -C target-cpu=native)

#![feature(asm)]

use std::alloc;

#[cfg(target_feature = "avx")]
fn main() {
    unsafe {
        let layout = alloc::Layout::from_size_align_unchecked(32, 32);
        let mem = alloc::alloc_zeroed(layout);
        asm!(
             "vmovdqa ymm0, [{source}]",
             source = in(reg) mem,
             out("ymm0") _,
        );
    }
}

Omitting (incorrectly) the register for the inputs and outputs does not cause a segfault.

#![feature(asm)]

use std::alloc;

#[cfg(target_feature = "avx")]
fn main() {
    unsafe {
        let layout = alloc::Layout::from_size_align_unchecked(32, 32);
        let mem = alloc::alloc_zeroed(layout);
        asm!(
             "vmovdqa ymm0, [{source}]",
             source = in(reg) mem,
        );
    }
}

xmm registers work fine even when they appear in outputs.

#![feature(asm)]

use std::alloc;

fn main() {
    unsafe {
        let layout = alloc::Layout::from_size_align_unchecked(16, 16);
        let mem = alloc::alloc_zeroed(layout);
        asm!(
             "movdqa xmm0, [{source}]",
             source = in(reg) mem,
             out("xmm0") _,
        );
    }
}

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (8ad7bc3f4 2020-07-21)
binary: rustc
commit-hash: 8ad7bc3f428300aee6764f6e23527e19eb235e81
commit-date: 2020-07-21
host: x86_64-apple-darwin
release: 1.47.0-nightly
LLVM version: 10.0

Error output

There is no output, rustc segfaults before emitting any.

@in-the-mood-for-mov in-the-mood-for-mov added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 22, 2020
@jonas-schievink jonas-schievink added F-asm `#![feature(asm)]` (not `llvm_asm`) 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. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 22, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 17, 2020
Work around LLVM issues with explicit register in inline asm

Fixes rust-lang#74658
@bors bors closed this as completed in 9198e8a Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) 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

Successfully merging a pull request may close this issue.

2 participants