-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIMD [iu]8xN tests SIGILL in --release #88769
Comments
During my reduction, this nice error popped up which is, at least I think so, the real error message behind this ICE:
I post my code in ~10 Minutes, after cleaning it up |
This ICE is very fragile, even removing the #![feature(platform_intrinsics, repr_simd)]
extern "platform-intrinsic" {
pub(crate) fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
}
#[repr(simd)]
pub struct Simd<T, const LANES: usize>([T; LANES]);
impl<T, const LANES: usize> Simd<T, LANES> {
pub fn new(array: [T; LANES]) -> Self {
Self(array)
}
}
mod biteq {
pub trait BitEq {
fn biteq(&self, other: &Self) -> bool;
}
impl BitEq for i8 {
fn biteq(&self, _: &Self) -> bool {
false
}
}
pub struct BitEqWrapper<T>(pub T);
impl<T: BitEq> PartialEq for BitEqWrapper<T> {
fn eq(&self, _: &Self) -> bool {
false
}
}
}
fn main() {
pub fn implementation(x: [i8; 16]) {
use crate::biteq::BitEqWrapper;
let a = unsafe { crate::simd_reduce_mul_ordered(crate::Simd::<i8, 16>::new(x), 1) };
let b = 0;
let left = BitEqWrapper(a);
let right = BitEqWrapper(b);
let _ = left == right;
}
implementation([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
}
Backtrace
Gdb:
based on the error message: @rustbot modify labels: I-crash I-monomorphization |
is the assertion being triggered (with @hellow554's minimization) |
I do not understand how that is finding a null pointer or how it is getting a poison value out of this. |
Thank you for your work on the minimization though! I just... is it because it starts as an array and then it tries to constant fold that? And why only vectors of 8-bit values? The test is the same for larger ones. |
As a note, this crash only reproduces with |
I can repro with this: But only on |
Running with These series of steps reproduce the crash outside mkdir issue-88769
cd issue-88769
curl -sSO https://gist.githubusercontent.com/eddyb/08ea4736082d9b2326a984c4cb828a08/raw/6a2b96cd8422950fa2b160e518671df66965a863/issue-88769-min.rs
rustup toolchain install nightly-2021-09-08 -c llvm-tools-preview
# This will crash - ignore the crash and keep going, `-C save-temps` works.
rustc +nightly-2021-09-08 issue-88769-min.rs -O -C save-temps
# This reproduces the crash using the `.bc` from `-C save-temps`.
~/.rustup/toolchains/nightly-2021-09-08-x*64*/lib/rustlib/x*64*/bin/opt -O3 issue-88769-min.*-cgu.3.rcgu.no-opt.bc > opt.bc Sadly we don't ship bugpoint --opt-command=$(echo ~/.rustup/toolchains/nightly-2021-09-08-x*64*/lib/rustlib/x*64*/bin/opt) -O3 issue-88769-min.*-cgu.3.rcgu.no-opt.bc After a lot of crashes, it ends in:
Running ; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "issue_88769_min.61742fa9-cgu.3"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define dso_local void @_ZN15issue_88769_min4main17h9167823f857de443E() unnamed_addr #0 {
%1 = call i8 @llvm.vector.reduce.mul.v16i8(<16 x i8> bitcast (<1 x i128> <i128 20011376718272490338853433276725592320> to <16 x i8>))
store i8 %1, i8* undef, align 1
ret void
}
; Function Attrs: nofree nosync nounwind readnone willreturn
declare i8 @llvm.vector.reduce.mul.v16i8(<16 x i8>) #1
attributes #0 = { "target-cpu"="x86-64" }
attributes #1 = { nofree nosync nounwind readnone willreturn }
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"RtLibUseGOT", i32 1} cc @nikic ( |
Just to confirm: crash repros on mkdir issue-88769
cd issue-88769
curl -sSO https://gist.githubusercontent.com/eddyb/08ea4736082d9b2326a984c4cb828a08/raw/6a2b96cd8422950fa2b160e518671df66965a863/issue-88769-min.rs
rustup toolchain install nightly-2021-08-22 -c llvm-tools-preview
# This will crash - ignore the crash and keep going, `-C save-temps` works.
rustc +nightly-2021-08-22 issue-88769-min.rs -O -C save-temps
# This reproduces the crash using the `.bc` from `-C save-temps`.
~/.rustup/toolchains/nightly-2021-08-22-x*64*/lib/rustlib/x*64*/bin/opt -O3 issue-88769-min.*-cgu.3.rcgu.no-opt.bc > opt.bc |
@eddyb Thanks for the reduction, upstream issue filed in https://bugs.llvm.org/show_bug.cgi?id=51811. |
Should be fixed by #88765. |
Okay, trying to compile our test still appears to crash |
The LLVM-level repro and hellow's minimization both seem to be fixed. |
The reduction above now works on nightly, but portable-simd still fails on the same test with the same error as the original report. I'm guessing the bug is only partially fixed in LLVM? |
I can confirm that my reduced testcase is indeed fixed, but portable-simd still fails on linux and windows. I'll try it again :) It seems not to be a llvm issue anymore, but a rust (jobserver) one? It panicks with a SIGTRAP under linux, here's the backtrace: thread1:
thread2:
|
MCVE: #![feature(platform_intrinsics, repr_simd)]
#[repr(simd)]
pub struct Simd<T, const LANES: usize>([T; LANES]);
impl<const LANES: usize> Simd<i8, LANES> {
pub fn horizontal_product(self) -> i8 {
extern "platform-intrinsic" {
fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
}
unsafe { simd_reduce_mul_ordered(self, 1) }
}
}
fn cb(x: [i8; 16]) {
let a: i8 = Simd(x).horizontal_product();
let _ = a.to_string();
}
fn main() {
let x = [0; 16];
let _ = std::panic::catch_unwind(|| cb(x));
} Regressed in db002a0 so it is an llvm issue after all? |
Reduced:
|
Upstream report: https://bugs.llvm.org/show_bug.cgi?id=51858 |
What appears to be a fix? is now present upstream at llvm/llvm-project@dcba994 |
Update LLVM submodule This merges the upstream `release/13.x` branch to pull in the second fix for rust-lang#88769.
Should be fixed by #89130 -- unless there's a third bug? |
I re-ran a test and it appears fixed, thanks! I'll wait for @workingjubilee to confirm. |
Ditto! No third bug this time. 😅 Thank you so much! |
Hello, we have encountered an issue in the portable-simd CI unique to tests on our
i8xN
andu8xN
types on x86_64. It emits a SIGTRAP, or sometimes a SIGILL, or on Windows, a STATUS_ACCESS_VIOLATION! How exciting! I can reproduce this locally. Our other tests do not do this, and it only happens in--release
, so I suspect this is a miscompilation by LLVM 13 inappropriately optimizing something. Full command to repro:cargo test --release --test [iu]8_ops
I am going to try to minimize this from "literally the entire test suite" but I might take a bit. The issue became apparent about 7 days ago. Tests were passing about 20
30 days ago (August 818) judging by the last green in rust-lang/portable-simd#155. I believe the time frame is correct for this to have been due to #87570More minutiae
RUSTFLAGS="-Copt-level=1"
passes with the above tests.RUSTFLAGS="-Copt-level=2"
crashes with them.Version it worked on
It most recently worked on: Rust 1.56 nightly (2021-07-17)
Version with regression
rustc --version --verbose
:but it also happened on rustc 1.57.0-nightly 2021-09-01
Sample Crash
The text was updated successfully, but these errors were encountered: