Skip to content

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

Closed
@in-the-mood-for-mov

Description

@in-the-mood-for-mov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)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.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