Skip to content

Invalid loads in core::simd::splat for vectors with >= 4 elements. #605

Open
@FractalFir

Description

@FractalFir

Calling core::simd::u8x4::splat(or any splat with 4 or more elements) with -fsantize=undefined results in invalid loads:

   // OK
   println!("u8x1");
    let v = simd::u8x1::splat(8);
    black_box(v);
    println!("u8x2");
    let v = simd::u8x2::splat(8);
    black_box(v);
    // Memory error
    println!("u8x4");
    let v = simd::u8x4::splat(8);
    black_box(v);
u8x1
u8x2
u8x4
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd230 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd230: note: pointer points here
 ff 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  7c d2 6f 8d
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd231 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd231: note: pointer points here
 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  7c d2 6f 8d ff
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd230 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd230: note: pointer points here
 ff 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  7c d2 6f 8d
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd231 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd231: note: pointer points here
 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  7c d2 6f 8d ff
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd230 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd230: note: pointer points here
 ff 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  08 08 00 00
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd231 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd231: note: pointer points here
 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  08 08 00 00 00
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd230 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd230: note: pointer points here
 ff 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  08 08 00 00
              ^ 
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7fff8d6fd231 with insufficient space for an object of type 'unsigned char'
0x7fff8d6fd231: note: pointer points here
 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  08 08 00 00 00 00 00 00  08 08 00 00 00
              ^ 

This issue only occurs for vectors with more than 4 elements - the type of the element does not matter:

u64x4
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7ffce42ec4f0 with insufficient space for an object of type 'size_t'
0x7ffce42ec4f0: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  40 81 f4 cb 73 55 00 00  d8 c4 2e e4
              ^ 
f32x4
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7ffce42ec620 with insufficient space for an object of type '<unknown>'
0x7ffce42ec620: note: pointer points here
 00 00 00 41  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  a0 80 f4 cb 73 55 00 00  00 00 00 41
              ^ 
i8x4
/home/michal/rustc_codegen_gcc/build/build_sysroot/sysroot_src/library/core/src/../../portable-simd/crates/core_simd/src/swizzle.rs:90:13: runtime error: load of address 0x7ffce42ec5f0 with insufficient space for an object of type 'signed char'
0x7ffce42ec5f0: note: pointer points here
 fc 7f 08 08  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  3c c6 2e e4

This issue(discovered when running the core test suite) does not seem to lead to crashes / incorrect behavaiour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions