Skip to content

neon vst1_* intrinsics copy many more bytes than they should. #1220

Closed
@HEnquist

Description

@HEnquist

This was introduces in this commit:
907cfb2

For example:

pub unsafe fn vst1q_f64(ptr: *mut f64, a: float64x2_t) {

pub unsafe fn vst1q_f64(ptr: *mut f64, a: float64x2_t) {
    copy_nonoverlapping(
        &a as *const float64x2_t as *const f64,
        ptr as *mut f64,
        size_of::<float64x2_t>(),
    )
}

The docs for copy_nonoverlapping says "Copies count * size_of::() bytes from src to dst"
The example above will get called with type T = f64 (with size 8 bytes), and count = size_of::<float64x2_t> = 16. So it will end up copying 8*16=128 bytes. That's quite a bit more than the 16 bytes it should have been.
The result is that it writes garbage to memory locations it should not touch.

https://doc.rust-lang.org/core/ptr/fn.copy_nonoverlapping.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions