Skip to content

xabort incorrect argument #73814

@valarauca

Description

@valarauca

I tried this code:

godbolt link, you need to pass platform features.

#![no_std]
#![feature(stdsimd)]
use core::arch::x86_64::{_xabort, _xtest};

pub fn abort(x: i8) {
    unsafe {
        if _xtest() {
            _xabort(x);
        }
    }
}

I expected to see this happen:

Either a clean compile, or a type error that u8 was expected instead of i8.

Instead, this happened:

The current code states that _xabort takes a u32 as an argument. This appears to be incorrect.

As the xabort instruction can only encode an 8bit argument.

The xbegin instruction will only encode the abort flag within bits 24:31 of eax. Meaning that you can't recieve an error code larger than 8bits.

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (7750c3d46 2020-06-26)
binary: rustc
commit-hash: 7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772
commit-date: 2020-06-26
host: x86_64-unknown-linux-gnu
release: 1.46.0nightly
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions