rust-lang / rust-lang/rustc_codegen_gcc
Invalid loads in core::simd::splat for vectors with >= 4 elements.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 105
- Avg merge
- 8h 20m
- Merged PRs (30d)
- 14
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the core test-suite failure with undefined-behavior sanitization and inspect portable-simd/crates/core_simd/src/swizzle.rs at line 90, where the invalid loads are reported. Compare splat behavior for vectors below and at four elements across the shown element types; done means the sanitizer reports no invalid loads while the relevant core tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100