Neon miscompilation in stdarch tests with SeparateConstSwitch enabled #112460
Labels
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-critical
Critical priority
Some stdarch Neon tests have started failing, I think due to a code generation error. An example is
test_vld2q_dup_f32
, and this is the first one hit with an unfilteredcargo test
.I've not yet been able to reduce the stdarch test down to a standalone example. (At least, not one that also triggers this bug.) Inside the Docker container that stdarch uses for its tests (
ci/run-docker.sh armv7-unknown-linux-gnueabihf
):The first two lanes of each result vector actually seem to be uninitialised; in my brief investigation I've seen different values there.
One curiosity is that the the symbol (
test_vld2q_dup_f32
) doesn't actually exist in the generated ELF, but I think I found the code using GDB (namedcore::ops::function::FnOnce::call_once::h81d7cb0a06a6ffb8
). I assume this is a consequence of the optimisation path, or some kind of inlining. In any case, the code does look incorrect, at a glance:That
vcmp.f32
comparess4
(which is the lower 32 bits ofd2
), but we never loaded that. (It isn't written earlier in the function either.)A good compilation stores the results back to an array an calls
core::array::equality::<impl core::cmp::PartialEq<[B; N]> for [A; N]>::eq
, so perhaps this is an inlining error.Meta
The first failing nightly is
nightly-2023-06-02
(d59363ad0
), but I bisected the problem down to 89bf30e73d97. However, that commit simply enabled an optimisation pass. Manually enabling the pass in older nightlies shows exactly the same fault.The following reproduces the bug on older nightlies (at least back to
nightly-2023-03-25
):I think this is probably a rustc bug, but I have not ruled out a bug in stdarch or some SIMD infrastructure it uses.
The text was updated successfully, but these errors were encountered: