Skip to content

fix(bb): unaligned SIMD store in Constantine x4 recoder (nightly debug segfault)#23813

Draft
AztecBot wants to merge 1 commit into
nextfrom
cb/fix-pippenger-constantine-simd-segfault
Draft

fix(bb): unaligned SIMD store in Constantine x4 recoder (nightly debug segfault)#23813
AztecBot wants to merge 1 commit into
nextfrom
cb/fix-pippenger-constantine-simd-segfault

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented Jun 3, 2026

Summary

The Nightly Debug Build failed (exit 139 / SIGSEGV) in ecc_tests:

FAILED: barretenberg/cpp/scripts/run_test.sh ecc_tests PippengerConstantine.SimdX4MatchesScalarPathLanewise (code: 139)
timeout: the monitored command dumped core

The test crashes immediately at [ RUN ], in the debug build only.

Root cause

simd_u32x4_store in pippenger_constantine.hpp (introduced in #23562) stored the 4-wide vector with:

*reinterpret_cast<SimdU32x4*>(dst) = v;

SimdU32x4 is a uint32_t __attribute__((vector_size(16))) type with 16-byte natural alignment, so this is an aligned vector store (movdqa on SSE2). But dst comes from a std::array<uint32_t, 4> in the test/fuzzer, which is only 4-byte aligned. Storing 16 aligned bytes to a 4-byte-aligned address faults.

The helper's own comment already documented the intended lowering as the unaligned movups / st1 — the implementation just didn't match it. In optimized builds the stack layout happened to land the array on a 16-byte boundary (or the store got reassociated), so the fault only surfaced reliably at -O0 in the nightly debug build.

Fix

Use __builtin_memcpy, which does not assume over-alignment of dst. Codegen verified:

  • -O2 x86 SSE2: a single movups %xmm0, (%rdi) — same intended unaligned store, no perf regression.
  • -O0: spills via aligned stack slot then copies — no aligned store to dst, no fault.

The WASM path (wasm_v128_store, which is alignment-agnostic) is unchanged.

Verification (red/green, debug preset)

Reproduced and fixed in build-debug on the exact failing commit:

  • Buggy aligned store → PippengerConstantine.SimdX4MatchesScalarPathLanewise exits 139 at [ RUN ] (matches CI).
  • With the fix → all 6 PippengerConstantine.* tests pass.

The SIMD x4 helpers are currently only exercised by the unit test and fuzzer (not yet wired into scalar_multiplication.cpp), so this is a test/codegen correctness fix with no behavioural change to the MSM.


Created by claudebox · group: slackbot

@AztecBot AztecBot added ci-barretenberg Run all barretenberg/cpp checks. claudebox Owned by claudebox. it can push to this PR. labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-barretenberg Run all barretenberg/cpp checks. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant