Skip to content

compiler fails on arithmetic operations #134457

Closed
@ohad-agadi

Description

@ohad-agadi

I have a struct representing circle points over field elements (represented as u32)

impl<F: Zero + Add<Output = F> + FieldExpOps + Sub<Output = F> + Neg<Output = F>> Add
    for CirclePoint<F>
{
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        let x = self.x.clone() * rhs.x.clone() - self.y.clone() * rhs.y.clone();
        let y = self.x * rhs.y + self.y * rhs.x;
        Self { x, y }
    }
}

link to the code: https://github.com/starkware-libs/stwo/blob/4053f974dcd29812a8c775205bc107e56a026a5b/crates/prover/src/core/circle.rs#L126-L134

running cargo bench with RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512f -C opt-level=3",
the compiler fails with the following error:
error: rustc interrupted by SIGSEGV, backtrace is given below

however, the following code does manage to compile:

impl<F: Zero + Add<Output = F> + FieldExpOps + Sub<Output = F> + Neg<Output = F>> Add
    for CirclePoint<F>
{
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        let x = self.x.clone() * rhs.x.clone() + (- self.y.clone() * rhs.y.clone());
        let y = self.x * rhs.y + self.y * rhs.x;
        Self { x, y }
    }
}

Meta

rustc --version --verbose:

nightly 2024-12-16
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(+0x3720263)[0x7a421d120263]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7a4219819520]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm17SLPVectorizerPass22vectorizeChainsInBlockEPNS_10BasicBlockERNS_13slpvectorizer7BoUpSLPE+0x6b0)[0x7a4217f6e7b0]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm17SLPVectorizerPass7runImplERNS_8FunctionEPNS_15ScalarEvolutionEPNS_19TargetTransformInfoEPNS_17TargetLibraryInfoEPNS_9AAResultsEPNS_8LoopInfoEPNS_13DominatorTreeEPNS_15AssumptionCacheEPNS_12DemandedBitsEPNS_25OptimizationRemarkEmitterE+0x1191)[0x7a421811ba55]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm17SLPVectorizerPass3runERNS_8FunctionERNS_15AnalysisManagerIS1_JEEE+0x1cb)[0x7a421811a81d]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(+0x691a64d)[0x7a421811a64d]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm11PassManagerINS_8FunctionENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x76d)[0x7a4217a1bebb]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm27ModuleToFunctionPassAdaptor3runERNS_6ModuleERNS_15AnalysisManagerIS1_JEEE+0x38d)[0x7a4217a141cd]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(+0x6213e2b)[0x7a4217a13e2b]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/libLLVM.so.19.1-rust-1.85.0-nightly(_ZN4llvm11PassManagerINS_6ModuleENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x22b)[0x7a42180e336b]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(LLVMRustOptimize+0x84d)[0x7a421f7c9ed9]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(+0x5dc63ab)[0x7a421f7c63ab]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(+0x5dc5efe)[0x7a421f7c5efe]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(_RNvXs1_Cs3ztSSGqllq_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCs43NrWYAXHhA_17rustc_codegen_ssa6traits5write19WriteBackendMethods12optimize_fat+0x34)[0x7a421cf9d6a4]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(_RINvNtNtCsbfBZt64eLhN_3std3sys9backtrace28___rust_begin_short_backtraceNCINvXs0_Cs3ztSSGqllq_18rustc_codegen_llvmNtB1g_18LlvmCodegenBackendNtNtNtCs43NrWYAXHhA_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2j_4back5write10spawn_workB1N_E0uE0uEB1g_+0xc21)[0x7a421f7aa961]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(+0x5dbd9ea)[0x7a421f7bd9ea]
/home/runner/.rustup/toolchains/nightly-2024-12-16-x86_64-unknown-linux-gnu/lib/librustc_driver-373018000622b1f2.so(+0x5dbddc1)[0x7a421f7bddc1]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3)[0x7a421986bac3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x44)[0x7a42198fca04

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions