Skip to content

fix: add bounds checking to SrsInitSrs to fix debug build test#21985

Merged
federicobarbacovi merged 6 commits intomerge-train/barretenbergfrom
claudebox/18de9a76f76d4b73-2
Mar 27, 2026
Merged

fix: add bounds checking to SrsInitSrs to fix debug build test#21985
federicobarbacovi merged 6 commits intomerge-train/barretenbergfrom
claudebox/18de9a76f76d4b73-2

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented Mar 25, 2026

Summary

Fixes nightly barretenberg debug build failures.

1. CBind.CatchesExceptionAndReturnsErrorResponse test (bbapi_srs.cpp)

The test relied on undefined behavior (buffer overread in from_buffer) to trigger an exception. In debug builds, the UB silently reads garbage and returns success instead of throwing. Fix: add proper bounds validation to SrsInitSrs::execute and SrsInitGrumpkinSrs::execute.

2. ChonkRecursionConstraintTest.GenerateRecursiveChonkVerifierVKFromConstraints (pairing_points.hpp)

In VK generation mode (write_vk), witnesses are zero-initialized and the recursive verifier runs on structurally-correct but numerically-meaningless dummy data. The stdlib curve operations produce intermediate/final pairing points whose native values (extracted via .get_value()) are garbage — they don't satisfy y² = x³ + 3. The stdlib PairingPoints constructor has a debug-only (#ifndef NDEBUG) sanity check that calls native_pp.check()reduced_ate_pairing_batch_precomputed()throw_or_abort() on these off-curve points. In release builds this check is compiled out entirely. Fix: wrap the debug-only native pairing checks in try-catch so they log the failure without crashing.

Test Plan

  • All 15 bbapi tests pass in debug mode
  • ChonkRecursionConstraintTest.GenerateRecursiveChonkVerifierVKFromConstraints passes in debug mode
  • ChonkTests.Basic passes in debug mode"

@AztecBot AztecBot added ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR. labels Mar 25, 2026
@AztecBot AztecBot force-pushed the claudebox/18de9a76f76d4b73-2 branch from 7433323 to dfb10fc Compare March 25, 2026 21:13
AztecBot and others added 5 commits March 26, 2026 14:41
…g build test

The CBind.CatchesExceptionAndReturnsErrorResponse test relied on undefined
behavior (buffer overread) to trigger an exception. In debug builds, the UB
silently reads garbage and returns success instead of throwing, causing the
test to fail.

Add proper bounds validation to SrsInitSrs::execute and
SrsInitGrumpkinSrs::execute before accessing raw buffer pointers. This
ensures the test works reliably in all build modes and eliminates the
underlying UB.
Two fixes for debug build:

1. Legacy CRS fallback: when compressed CRS (bn254_g1_compressed.dat) is not
   available but old uncompressed CRS (bn254_g1.dat) exists, read the
   uncompressed format directly. This ensures tests work on machines that
   haven't re-downloaded the CRS after the compression change in #21112.

2. Non-throwing debug pairing checks: the stdlib PairingPoints constructor and
   aggregate() method perform native pairing verification in debug builds
   (#ifndef NDEBUG). When mock/dummy data produces invalid points (e.g. during
   VK generation with cleared witnesses), this threw an uncatchable exception.
   Wrapped these debug-only checks in try-catch so they log failures without
   crashing.
@federicobarbacovi federicobarbacovi force-pushed the claudebox/18de9a76f76d4b73-2 branch from dfb10fc to fb3140e Compare March 26, 2026 14:41
@federicobarbacovi federicobarbacovi marked this pull request as ready for review March 26, 2026 15:02
Base automatically changed from merge-train/barretenberg to next March 26, 2026 15:45
@federicobarbacovi federicobarbacovi added this pull request to the merge queue Mar 27, 2026
@federicobarbacovi federicobarbacovi removed this pull request from the merge queue due to a manual request Mar 27, 2026
@federicobarbacovi federicobarbacovi changed the base branch from next to merge-train/barretenberg March 27, 2026 11:14
@federicobarbacovi federicobarbacovi merged commit 401ff2a into merge-train/barretenberg Mar 27, 2026
17 checks passed
@federicobarbacovi federicobarbacovi deleted the claudebox/18de9a76f76d4b73-2 branch March 27, 2026 11:17
github-merge-queue bot pushed a commit that referenced this pull request Mar 27, 2026
BEGIN_COMMIT_OVERRIDE
chore: fixes in ecc/group internal audit (#21920)
fix: add bounds checking to SrsInitSrs to fix debug build test (#21985)
chore: Refactor chonk.cpp (#22055)
fix: a bunch of minor fixes (#21993)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants