fix: add bounds checking to SrsInitSrs to fix debug build test#21985
Merged
federicobarbacovi merged 6 commits intomerge-train/barretenbergfrom Mar 27, 2026
Merged
fix: add bounds checking to SrsInitSrs to fix debug build test#21985federicobarbacovi merged 6 commits intomerge-train/barretenbergfrom
federicobarbacovi merged 6 commits intomerge-train/barretenbergfrom
Conversation
7433323 to
dfb10fc
Compare
…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.
dfb10fc to
fb3140e
Compare
johnathan79717
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes nightly barretenberg debug build failures.
1.
CBind.CatchesExceptionAndReturnsErrorResponsetest (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 toSrsInitSrs::executeandSrsInitGrumpkinSrs::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 stdlibPairingPointsconstructor has a debug-only (#ifndef NDEBUG) sanity check that callsnative_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
ChonkRecursionConstraintTest.GenerateRecursiveChonkVerifierVKFromConstraintspasses in debug modeChonkTests.Basicpasses in debug mode"